General Code Review Thread.
#1
Hello GS! In this thread you are invited to post any code you would like to have reviewed. The idea is, that we post our code and go over it together, to give each other tips, constructive criticism and maybe some pointers. In this way we will collaboratively improve each others work and hopefully learn something in the process. Whether you are an expert or a beginner it's often good to have a second pair of eyes go over your work in order to improve it.

All languages are accepted and everyone is encouraged to participate. Also, with regards to beginners, don't be afraid to ask questions or even point out a flaw you may see in someone else's code. Everyone here is human and we all make mistakes from time to time.

Just post your code in code tags below along with any questions or comments you might have. Thanks!
Reply
#2
Let me start, here is my latest little project, a vulnerabilities parser from CVE details, for anyone who wants to get the latest exploits/vulnerabilities directly from the terminal without the need to open the browser. Let me know what do you think/reviews.

Code:
#!/usr/bin/env python2

try:
    import requests, json, argparse
except ImportError:
    print "[!] Error importing one or more library(ies)!\n[~] Leaving ...\n\n"
    exit(-1)

def parseCVE(query):
    url = "http://www.cvedetails.com/json-feed.php?"+query
    req = requests.get(url)
    CVE_List = req.text
    CVE_List = json.loads(CVE_List)
    for i in CVE_List:
        print '[~] CVE ID: %s' % (i['cve_id'])
        print '[~] CWE ID: %s' % (i['cwe_id'])
        print '[~] CVSS Score: %s' % (i['cvss_score'])
        print '[~] Exploit Count: %s' % (i['exploit_count'])
        print '[~] Publish Date: %s' % (i['publish_date'])
        print '[~] Update Date: %s' % (i['update_date'])
        print '[~] CVE URL:\n%s' % (i['url'])
        print '[~] CVE Summary:\n%s' % (i['summary'])
        print '\n\n###############################################################\n\n'


if __name__ == "__main__":
    ArgumentHandler = argparse.ArgumentParser(description = "Vulnerabilities & Exploits CVE CLI Parser")
    ArgumentHandler.add_argument("-n", "--num"   , help = "Number of CVE's to parse" , required = True)
    ArgumentHandler.add_argument("-s", "--score" , help = "Score larger than or equal to " , required = True)
    ArgumentHandler.add_argument("-a", "--all"   , help = "Search in all vulnerabilities' types" , action = "store_true")
    ArgumentHandler.add_argument("-o", "--overflow" , help = "Search in Overflow vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-c", "--codeexec" , help = "Search in Code Execution vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-f", "--fileinc"  , help = "Search in File Inclusion vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-x", "--xss" , help = "Search in Cross Site Scripting vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-d", "--ddos" , help = "Search in DDoS vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-p", "--priv" , help = "Search in Privilege Escalation vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-t", "--trav" , help = "Search in Directory Traversal vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-S", "--sqlinj" , help = "Search in SQL Injection vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-M", "--mem" , help = "Search in Memory Corruption vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-R", "--csrf" , help = "Search in CSRF vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-E", "--exploits" , help = "Search vulnerabilities with exploits" , action = "store_true")

    args = ArgumentHandler.parse_args()

    if args.all:
        query = "numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec=1&opov=1&opcsrf=1&opfileinc=1&opgpriv=1&opsqli=1&opxss=1&opdirt=1&opmemc=1&ophttprs=1&opbyp=1&opginf=1&opdos=1&orderby=1&cvssscoremin=0".format(args.num)
    else:
        query = "numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec={1}&opov={2}&opcsrf={3}&opfileinc={4}&opgpriv={5}&opsqli={6}&opxss={7}&opdirt={8}&opmemc={9}&ophttprs=1&opbyp=1&opginf=1&opdos={10}&orderby=1&cvssscoremin={11}".format(args.num, 1 if args.codeexec else 0, 1 if args.overflow else 0, 1 if args.csrf else 0, 1 if args.fileinc else 0, 1 if args.priv else 0, 1 if args.sqlinj else 0, 1 if args.xss else 0, 1 if args.trav else 0, 1 if args.mem else 0, 1 if args.ddos else 0, args.score)

    parseCVE(query)
Reply
#3
(05-19-2017, 12:04 PM)Hysteresis Wrote: Let me start, here is my latest little project, a vulnerabilities parser from CVE details, for anyone who wants to get the latest exploits/vulnerabilities directly from the terminal without the need to open the browser. Let me know what do you think/reviews.

Code:
#!/usr/bin/env python2

try:
    import requests, json, argparse
except ImportError:
    print "[!] Error importing one or more library(ies)!\n[~] Leaving ...\n\n"
    exit(-1)

def parseCVE(query):
    url = "http://www.cvedetails.com/json-feed.php?"+query
    req = requests.get(url)
    CVE_List = req.text
    CVE_List = json.loads(CVE_List)
    for i in CVE_List:
        print '[~] CVE ID: %s' % (i['cve_id'])
        print '[~] CWE ID: %s' % (i['cwe_id'])
        print '[~] CVSS Score: %s' % (i['cvss_score'])
        print '[~] Exploit Count: %s' % (i['exploit_count'])
        print '[~] Publish Date: %s' % (i['publish_date'])
        print '[~] Update Date: %s' % (i['update_date'])
        print '[~] CVE URL:\n%s' % (i['url'])
        print '[~] CVE Summary:\n%s' % (i['summary'])
        print '\n\n###############################################################\n\n'


if __name__ == "__main__":
    ArgumentHandler = argparse.ArgumentParser(description = "Vulnerabilities & Exploits CVE CLI Parser")
    ArgumentHandler.add_argument("-n", "--num"   , help = "Number of CVE's to parse" , required = True)
    ArgumentHandler.add_argument("-s", "--score" , help = "Score larger than or equal to " , required = True)
    ArgumentHandler.add_argument("-a", "--all"   , help = "Search in all vulnerabilities' types" , action = "store_true")
    ArgumentHandler.add_argument("-o", "--overflow" , help = "Search in Overflow vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-c", "--codeexec" , help = "Search in Code Execution vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-f", "--fileinc"  , help = "Search in File Inclusion vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-x", "--xss" , help = "Search in Cross Site Scripting vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-d", "--ddos" , help = "Search in DDoS vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-p", "--priv" , help = "Search in Privilege Escalation vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-t", "--trav" , help = "Search in Directory Traversal vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-S", "--sqlinj" , help = "Search in SQL Injection vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-M", "--mem" , help = "Search in Memory Corruption vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-R", "--csrf" , help = "Search in CSRF vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-E", "--exploits" , help = "Search vulnerabilities with exploits" , action = "store_true")

    args = ArgumentHandler.parse_args()

    if args.all:
        query = "numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec=1&opov=1&opcsrf=1&opfileinc=1&opgpriv=1&opsqli=1&opxss=1&opdirt=1&opmemc=1&ophttprs=1&opbyp=1&opginf=1&opdos=1&orderby=1&cvssscoremin=0".format(args.num)
    else:
        query = "numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec={1}&opov={2}&opcsrf={3}&opfileinc={4}&opgpriv={5}&opsqli={6}&opxss={7}&opdirt={8}&opmemc={9}&ophttprs=1&opbyp=1&opginf=1&opdos={10}&orderby=1&cvssscoremin={11}".format(args.num, 1 if args.codeexec else 0, 1 if args.overflow else 0, 1 if args.csrf else 0, 1 if args.fileinc else 0, 1 if args.priv else 0, 1 if args.sqlinj else 0, 1 if args.xss else 0, 1 if args.trav else 0, 1 if args.mem else 0, 1 if args.ddos else 0, args.score)

    parseCVE(query)


I like the program and what it does. Your implementation is efficient. There's two things i think that could be somewhat improved with regards to user friendliness and readability. What i always like to do when i have a script that takes command line arguments is have python check if there were any passed and if not print a little about it's usage information. Having the `argparse` module do it when there are no args passed isn't that effective in conveying information in my opinion. Of course the user could just start the script with the `--help` flag but we could spare them the trouble with a simple `if not len(sys.argv[1:]):`

Secondly, in your last `else` statement you have a long procession of ternary operators. That's ok but personally i would put each ternary on it's own line for readability. I took the liberty to refactor your code based on my review of it. Let me know what you think Smile  


Code:
#!/usr/bin/env python2

try:
    import requests, json, argparse, sys
except ImportError:
    print "[!] Error importing one or more library(ies)!\n[~] Leaving ...\n\n"
    exit(-1)

if not len(sys.argv[1:]):
    print """
Welcome to Vulnerabilities & Exploits CVE CLI Parser.

To start using the program please provide the required command line arguments
and their corresponding value where applicable.

Use '-n' or '--num' to indicate the amount of CVE's to be parsed.
And '-s' or '--score' to sort results based on their score rating,
larger than or equal to the integer value provided.

To list all options available please use '-h' or '--help'.

Examples:
CVEparser.py --help
CVEparser.py --xss -n 10 -s 5
                                                                """
    
    sys.exit(0)

def parseCVE(query):
    url = "http://www.cvedetails.com/json-feed.php?"+query
    req = requests.get(url)
    CVE_List = req.text
    CVE_List = json.loads(CVE_List)
    for i in CVE_List:
        print '[~] CVE ID: %s' % (i['cve_id'])
        print '[~] CWE ID: %s' % (i['cwe_id'])
        print '[~] CVSS Score: %s' % (i['cvss_score'])
        print '[~] Exploit Count: %s' % (i['exploit_count'])
        print '[~] Publish Date: %s' % (i['publish_date'])
        print '[~] Update Date: %s' % (i['update_date'])
        print '[~] CVE URL:\n%s' % (i['url'])
        print '[~] CVE Summary:\n%s' % (i['summary'])
        print '\n\n###############################################################\n\n'


if __name__ == "__main__":
    ArgumentHandler = argparse.ArgumentParser(description = "Vulnerabilities & Exploits CVE CLI Parser")
    ArgumentHandler.add_argument("-n", "--num"   , help = "Number of CVE's to parse" , required = True)
    ArgumentHandler.add_argument("-s", "--score" , help = "Score larger than or equal to " , required = True)
    ArgumentHandler.add_argument("-a", "--all"   , help = "Search in all vulnerabilities' types" , action = "store_true")
    ArgumentHandler.add_argument("-o", "--overflow" , help = "Search in Overflow vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-c", "--codeexec" , help = "Search in Code Execution vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-f", "--fileinc"  , help = "Search in File Inclusion vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-x", "--xss" , help = "Search in Cross Site Scripting vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-d", "--ddos" , help = "Search in DDoS vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-p", "--priv" , help = "Search in Privilege Escalation vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-t", "--trav" , help = "Search in Directory Traversal vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-S", "--sqlinj" , help = "Search in SQL Injection vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-M", "--mem" , help = "Search in Memory Corruption vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-R", "--csrf" , help = "Search in CSRF vulnerabilities" , action = "store_true")
    ArgumentHandler.add_argument("-E", "--exploits" , help = "Search vulnerabilities with exploits" , action = "store_true")

    args = ArgumentHandler.parse_args()

    if args.all:
        query = """
        numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec=1
        &opov=1&opcsrf=1&opfileinc=1&opgpriv=1&opsqli=1&opxss=1&opdirt=1
        &opmemc=1&ophttprs=1&opbyp=1&opginf=1&opdos=1&orderby=1&cvssscoremin=0""".format(args.num)
    else:
        query = """
        numrows={0}&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec={1}
        &opov={2}&opcsrf={3}&opfileinc={4}&opgpriv={5}&opsqli={6}&opxss={7}
        &opdirt={8}&opmemc={9}&ophttprs=1&opbyp=1&opginf=1&opdos={10}&orderby=1
        &cvssscoremin={11}""".format(args.num,
        1 if args.codeexec else 0,
        1 if args.overflow else 0,
        1 if args.csrf else 0,
        1 if args.fileinc else 0,
        1 if args.priv else 0,
        1 if args.sqlinj else 0,
        1 if args.xss else 0,
        1 if args.trav else 0,
        1 if args.mem else 0,
        1 if args.ddos else 0,
        args.score)

    parseCVE(query)
Reply
#4
Actually, I'm the worst when it comes to code readability. This is my third or maybe fourth project since I started using useful comments and good-looking indentations, before that my projects were a bunch of sequential statements. I was only caring about efficiency and having correct outputs in a limited time domain.
Your points are really important for code readability, I'll definitely consider them in my future projects, thanks Vector!
Reply
#5
Great idea for a thread! I'm generally not that adept at reading, criticizing or leaving feedback on code. I've always been more of a lazy codemonkey than a programmer. But this thread deserves to be sticked!

/Thread Stuck
Reply
#6
(05-19-2017, 09:09 PM)Hysteresis Wrote: Actually, I'm the worst when it comes to code readability. This is my third or maybe fourth project since I started using useful comments and good-looking indentations, before that my projects were a bunch of sequential statements. I was only caring about efficiency and having correct outputs in a limited time domain.
Your points are really important for code readability, I'll definitely consider them in my future projects, thanks Vector!


No problem, i'm happy to help, it's what the thread is for Smile


(05-19-2017, 10:15 PM)Insider Wrote: Great idea for a thread! I'm generally not that adept at reading, criticizing or leaving feedback on code. I've always been more of a lazy codemonkey than a programmer. But this thread deserves to be sticked!

/Thread Stuck

Thanks buddy. If you have any code of your own that you would like a second opinion on feel free to leave it in the thread for review, if you'd like to participate.
Reply
#7
I found this cheat sheet, I thought it would be nice to post it here: http://www.planetgeek.ch/wp-content/uplo...e-V2.4.pdf

It is a collection of common mistakes and what to do in order to code cleaner Smile
Reply
#8
(05-25-2017, 03:48 PM)enmafia2 Wrote: I found this cheat sheet, I thought it would be nice to post it here: http://www.planetgeek.ch/wp-content/uplo...e-V2.4.pdf

It is a collection of common mistakes and what to do in order to code cleaner Smile

Thanks enmafia i think the cheat sheet fits well with the spirit of the thread.
Reply
#9
There hasn't been a lot going on on the forum or in my personal endeavours as far as security and coding is concerned but i have been receiving a lot of good words about a program i wrote a bit ago. You may have seen it around the forum, since i have posted it here in the past. I just thought i would post it in the code review thread to get you guys' thoughts on the actual code itself and see if there is anything that can be improved, so that i may improve it.

Code:
#!/usr/bin/env python2.7

import pycurl
import pickle
import os.path, os, sys
import time
import StringIO
import json

from selenium import webdriver
from blessings import Terminal
from ipwhois import IPWhois
from pprint import pprint

t = Terminal()
c = pycurl.Curl()


# Check if PyCurl version supports OpenSSL, if not, rebuild.
if "OpenSSL" not in pycurl.version:
    print "\n[" + t.red("!") + "]Warning! Heuristics indicate your verion of PyCurl does not support OpenSSL."
        
    print "[" + t.green("+") + "]Detected PyCurl version: " + pycurl.version
    print "[" + t.green("+") + "]In order for Mimir to be able to connect to HoneyDB, OpenSSL is required."
        
    print "\n[" + t.magenta("?") + "]Would you like to automatically resolve this issue?"
    rebuild = raw_input("[Y]es/[N]o: ")
        
    if rebuild == 'y':
        print "\n[" + t.green("+") + "]Invoking 'rebuild.sh'...\n"
        time.sleep(1.5)
        
        try:    
            os.system("chmod +x rebuild.sh")
            os.system("./rebuild.sh")
        except Exception as e:
            print "\n[" + t.red("!") + "]Critical. An error was raised while attemting to invoke external utility"
            print e
            sys.exit(1)
            
        print "\n[" + t.green("+") + "]PyCurl has been rebuilt with OpenSSL support. All systems nominal."
        print "\n[" + t.green("+") + "]Mimir needs to be restarted for changes to take effect. Quitting..."
        time.sleep(2.5)
        sys.exit(1)
            
    elif rebuild == 'n':
        print "\n[" + t.green("+") + "]Not resolving."
        
    else:
         print "\n[" + t.red("!") + "]Unhandled option. Quitting."
         sys.exit(1)

            
        
print t.cyan("""

oooo     oooo ooooo oooo     oooo ooooo oooooooooo  
8888o   888   888   8888o   888   888   888    888
88 888o8 88   888   88 888o8 88   888   888oooo88  
88  888  88   888   88  888  88   888   888  88o  
o88o  8  o88o o888o o88o  8  o88o o888o o888o  88o8


                Threat Intel Interface
                           \n""")


# Check if we have API ID/key saved
if not os.path.isfile("HDB-api-ID.p"):
    
    print "[" + t.green("+") + "]Please provide your HoneyDB API ID\n"
    DB_API_ID = raw_input("API ID: ")
    
    pickle.dump(DB_API_ID, open( "HDB-api-ID.p", "wb" ))
    
    print "[" + t.green("+") + "]Please provide your HoneyDB API key\n"
    DB_API_KEY = raw_input("API key: ")
    
    pickle.dump(DB_API_KEY, open( "HDB-api-key.p", "wb" ))
    
    print "[" + t.green("+") + "]Your API data has been saved to 'HDB-api-ID.p' and 'HDB-api-key.p' in the current directory.\n"
    
else:
    
    try:
        DB_API_ID = pickle.load(open( "HDB-api-ID.p", "rb" ))
        DB_API_KEY = pickle.load(open( "HDB-api-key.p", "rb" ))
    except IOError as e:
        print "\n[" + t.red("!") + "]Critical. An IO error was raised while attempting to read API data.\n"
        print e
        
        sys.exit(1)
    
    ID_path = os.path.abspath("HDB-api-ID.p")
    KEY_path = os.path.abspath("HDB-api-key.p")
    
    print "\n[" + t.green("+") + "]Your API ID was succesfully loaded from " + ID_path
    print "[" + t.green("+") + "]Your API key was succesfully loaded from " + KEY_path


# WHOIS function
def whois():
    print "[" + t.green("+") + "]Please provide an IP for WHOIS lookup."
    TARGET = raw_input("\n<" + t.cyan("WHOIS") + ">$ ")
    
    obj = IPWhois(TARGET)
    results = obj.lookup_rdap(depth=1)
    pprint(results)
    
    print "\n[" + t.magenta("?") + "]Would you like to append the WHOIS record to a text file?\n"
    logs = raw_input("[Y]es/[N]o: ")
    
    format = json.dumps(results, indent = 2)
    
    if logs == "y":
        with open( "whois.log", "ab" ) as outfile:
            outfile.write("Host: " + TARGET + "\n")
            outfile.write(format)
            outfile.close()
            
        print "[" + t.green("+") + "]Results saved to whois.log in the current directory.\n"
            
    elif logs == "n":
        print "[" + t.green("+") + "]Returning to main menu.\n"
        
    else:
        print "[" + t.red("!") + "]Unhandled Option.\n"

def hosts():
    a = StringIO.StringIO()
    
    # Options for PyCurl
    opts = ['X-HoneyDb-ApiId: ' + DB_API_ID, 'X-HoneyDb-ApiKey: ' + DB_API_KEY]
    c.setopt(pycurl.HTTPHEADER, (opts))
    c.setopt(pycurl.FOLLOWLOCATION, 1)
    
    c.setopt(pycurl.URL, "https://riskdiscovery.com/honeydb/api/bad-hosts")
    c.setopt(c.WRITEDATA, a)
    
    try:
        c.perform()
    except Exception as e:
        print "\n[" + t.red("!") + "]Critical. An error was raised with the following message"    
        print e
            
    os.system("clear")
    print "\n\n[" + t.green("+") + "]Retrieved Bad Hosts, formatting..."
    time.sleep(1)
            
    response_h = json.loads(a. getvalue())
    pprint(response_h)
            
    format = json.dumps(response_h, indent = 2)

    with open('hosts.log', 'ab') as outfile:
        outfile.write(format)
        outfile.close()
                
    print "\n\nResults saved to 'hosts.log' in the current directory"

def feed():
    b = StringIO.StringIO()
    
    # Options for PyCurl
    opts = ['X-HoneyDb-ApiId: ' + DB_API_ID, 'X-HoneyDb-ApiKey: ' + DB_API_KEY]
    c.setopt(pycurl.HTTPHEADER, (opts))
    c.setopt(pycurl.FOLLOWLOCATION, 1)
            
    c.setopt(pycurl.URL, "https://riskdiscovery.com/honeydb/api/twitter-threat-feed")
    c.setopt(c.WRITEDATA, b)
    
    try:
        c.perform()
    except Exception as e:
        print "\n[" + t.red("!") + "]Critical. An error was raised with the following message"    
        print e
        
    os.system("clear")
    print "\n\n[" + t.green("+") + "]Retrieved Threat Feed, formatting..."
    time.sleep(1)
            
    response_f = json.loads(b. getvalue())
    pprint(response_f)
            
    format = json.dumps(response_f, indent = 2)

    with open('feed.log', 'ab') as outfile:
        outfile.write(format)
        outfile.close()
        
    
    print "\n\nResults saved to 'feed.log' in the current directory"

try:
    while True:

                            
        print "\n\n[" + t.green("+") + "]Welcome to Mimir. Please select an action."
        print """
1. Fetch Threat Feed            5. Visualize Top Malicious Hosts in Browser
2. Fetch Bad Host List            6. Visualize Top Targeted Services in Browser
3. Perform WHOIS Lookup            7. Visualize Results for Single Host in Browser
4. Invoke Nmap Scan                8. Quit
        
        """        
        option = raw_input("\n<" + t.cyan("MIMIR") + ">$ ")
        
        if option == '1':
            feed()
            
        elif option =='2':
            hosts()
            
        elif option == '3':
            whois()
        
        elif option == '4':
            host = raw_input("\n[" + t.green("+") + "]Please enter a target to scan: ")
            try:
                os.system("nmap -T4 -Pn --reason " + host)
            except Exception as e:
                print "\n[" + t.red("!") + "]Critical. An error was raised with the following message "
                print e
                
        elif option == '5':
            try:
                driver = webdriver.Firefox()
                driver.get("https://riskdiscovery.com/honeydb/#hosts")
            except:
                pass
                
        elif option == '6':
            try:
                driver = webdriver.Firefox()
                driver.get("https://riskdiscovery.com/honeydb/#services")
            except:
                pass
                
        elif option == '7':
            host = raw_input("\n[" + t.green("+") + "]Please enter a host: ")
            try:
                driver = webdriver.Firefox()
                driver.get("https://riskdiscovery.com/honeydb/#host/" + host )
            except:
                pass
                
        elif option == '8':
            break
            
        else:
            print "\n[" + t.red("!") + "]Unhandled Option."

except KeyboardInterrupt:
    print "\n\n[" + t.red("!") + "]Critical. User aborted."

I am going to guess in advance and say that you will point out how having a function for both `Bad Hosts` and `Threat Feed` is redundant. And you would be right to do so. Out of interest, tell me how you would do it instead.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Windows Source-Code Collection (1.3TB) Insider 2 12,966 08-09-2020, 09:59 PM
Last Post: Insider
  Funny Code Comments ashen 0 10,173 03-25-2018, 02:16 PM
Last Post: ashen
  iBoot source code ekultek 3 12,682 03-02-2018, 07:02 PM
Last Post: enmafia2
  Code Visualizing Tool Anthrax 2 9,942 11-14-2016, 05:08 AM
Last Post: NO-OP