├── Base64Encode.py ├── Base64SaltEncode.py ├── Md5Hash.py ├── PortScanningWithNmap.py ├── Python Etkileşimli Shell Alma ├── README.md ├── SimpleHTTPServer.py ├── UrlResponse.py └── txtFileToMD5.py /Base64Encode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | veri = raw_input("Base64 ile Sifrelenecek Veriyi Giriniz") 5 | sifre=veri.encode('base64','strict') 6 | print sifre 7 | -------------------------------------------------------------------------------- /Base64SaltEncode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | veri = raw_input("Base64 ile Sifrelenecek Veriyi Giriniz:") 6 | salt="qwey123" 7 | salt_veri=veri+salt 8 | sifre=salt_veri.encode('base64','strict') 9 | print sifre 10 | -------------------------------------------------------------------------------- /Md5Hash.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import md5 6 | 7 | hash=md5.new('hashlenecekmetin') 8 | hash.hexdigest() 9 | -------------------------------------------------------------------------------- /PortScanningWithNmap.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | 4 | # Nmap Setup --> http://xael.org/pages/python-nmap-en.html 5 | 6 | try: 7 | import nmap 8 | import re 9 | import os 10 | import argparse 11 | import urllib2 12 | 13 | 14 | 15 | 16 | except ImportError,e: 17 | import sys 18 | sys.stdout.write("%s\n" %e) 19 | sys.exit(1) 20 | 21 | 22 | 23 | class Tarama: 24 | def __init__(self): 25 | self.cmd_arg = "-n -Pn -sS -sV -T4 --top-ports 10" 26 | self.nmap_services_file = "/usr/share/nmap/nmap-services" 27 | self.nm = nmap.PortScanner() 28 | 29 | def get_service_name(self, port, proto): 30 | nmap_file = open(self.nmap_services_file,"r") 31 | service = "" 32 | for line in nmap_file: 33 | if re.search("([^\s]+)\s%d/%s\s"% (port, proto), line): 34 | service = re.search("([^\s]+)\s%d/%s\s"% (port, proto), line).groups(1)[0] 35 | break 36 | return service 37 | 38 | 39 | def run_scan(self,targets): 40 | self.nm.scan(hosts = "%s"% targets, arguments = "%s"% self.cmd_arg) 41 | 42 | 43 | for host in self.nm.all_hosts(): 44 | print "IP i ADRESINIZ",host 45 | print "\n" 46 | print("PORT STATE SERVICE") 47 | for proto in self.nm[host].all_protocols(): 48 | result = self.nm[host][proto].keys() 49 | result.sort() 50 | 51 | for port in result: 52 | res = str(port) + "/" + proto 53 | space = str(" " * (9 - len(res))) 54 | service = self.get_service_name(port, proto) 55 | state = self.nm[host][proto][port]['state'] 56 | space2 = str(" " * (10 - len(state))) 57 | print "%s/%s%s%s%s%s" % (port,proto,space,state,space2,service) 58 | 59 | 60 | print "Domain Adresi :" 61 | domain_name = raw_input("Domain adresi=") 62 | 63 | if __name__ == "__main__": 64 | parser = argparse.ArgumentParser(description='Nmap Ile Port Tarama Programi') 65 | try: 66 | tarama = Tarama() 67 | tarama.run_scan(domain_name) 68 | except Exception, e: 69 | print >> sys.stderr, "Hata: %s"% e 70 | sys.exit(2) 71 | -------------------------------------------------------------------------------- /Python Etkileşimli Shell Alma: -------------------------------------------------------------------------------- 1 | #Kaynak: http://netsec.ws/?p=337 2 | 3 | 4 | python -c 'import pty; pty.spawn("/bin/sh")' 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python For Security 2 | 3 | Python for Security : Basic Python Security Code Samples 4 | 5 | Python ile yazılmış Siber Güvenlik ile ilgili basit kod örnekleri 6 | -------------------------------------------------------------------------------- /SimpleHTTPServer.py: -------------------------------------------------------------------------------- 1 | import SimpleHTTPServer 2 | import SocketServer 3 | 4 | PORT = 8000 5 | 6 | Handler = SimpleHTTPServer.SimpleHTTPRequestHandler 7 | 8 | httpd = SocketServer.TCPServer(("", PORT), Handler) 9 | 10 | print "serving at port", PORT 11 | httpd.serve_forever() 12 | 13 | 14 | ################################################################ 15 | 16 | python -m SimpleHTTPServer PORT // Bulunduğu dizini sunucu yayınına açar. 17 | -------------------------------------------------------------------------------- /UrlResponse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import urllib2 5 | 6 | response = urllib2.urlopen('http://gurelahmet.com/') 7 | print response.info() 8 | response.close() 9 | -------------------------------------------------------------------------------- /txtFileToMD5.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | my_file = open("file.txt" , "r") 4 | 5 | for line in my_file: 6 | try: 7 | hash_object = hashlib.md5(line.strip()) 8 | print(hash_object.hexdigest()) 9 | 10 | except: 11 | print "Error" 12 | 13 | my_file.close() 14 | --------------------------------------------------------------------------------