Skip to content
Snippets Groups Projects
Select Git revision
  • 708829a0ab4e1de84b6ec099d5d38c0007f0e823
  • master default
  • medina
3 results

configure.py

Blame
  • Anže Žitnik's avatar
    Zitnik, Anze authored
    Squashed commit of the following:
    
    commit bccedf5c278490f6befcb0f4f37db7e588f6901d
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 12:42:54 2020 +0100
    
        CI...
    
    commit 5a7f5b4e03fd857683aa110da4f4d31c2fee03a5
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 12:36:57 2020 +0100
    
        CI...
    
    commit 39f9ec5bd410280afb2e856a44ce5ac5b390668d
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 10:41:58 2020 +0100
    
        CI...
    
    commit cf807354e8a65d7ca2c5af7c73c16ae1b04c6f0e
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 10:22:59 2020 +0100
    
        CI...
    
    commit a44ccefa3d2bb34016db540c3728375437f4f043
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 10:19:20 2020 +0100
    
        CI...
    
    commit 7fd21692f7f3629c94b8e7c4ff495a9740984439
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 10:17:54 2020 +0100
    
        CI...
    
    commit 8fdec3c7db52bf7b00f33de350df975a23496701
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Tue Feb 18 10:14:32 2020 +0100
    
        CI...
    
    commit e2ed633df6ec245edd62b7c6fb049730abe25db7
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Fri Feb 14 19:00:43 2020 +0100
    
        CI test update
    
    commit 650c02745260ed1e6f434aea8ab1d0d89cc648f7
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Fri Feb 14 18:57:47 2020 +0100
    
        CI test update
    
    commit a3f71bb2f249479dad74b1b6596399699c09ed4f
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Fri Feb 14 18:43:20 2020 +0100
    
        CI test update
    
    commit 9a85e5b849eb99a6e8811c859bfe6458f2c1aea0
    Author: Anže Žitnik <anze.zitnik@xlab.si>
    Date:   Fri Feb 14 18:31:29 2020 +0100
    
        Configuration parsing from JSON config file. Using Ubuntu 18.04 base image.
    708829a0
    History
    configure.py 1.50 KiB
    import os
    import json
    
    '''
    Supported scanners:
        - w3af
    '''
    
    
    def main():
        with open("/root/config.json", "r") as f_conf:
            config = json.load(f_conf)
    
        # configure cscan target
        target = config["target"]
        if "url" in target:
            f_t = open("/root/cscan/websites.txt", "w")
            f_t.write(target["url"])
            f_t.write(os.linesep)
            f_t.close()
        if "ip" in target:
            f_t = open("/root/cscan/ips.txt", "w")
            f_t.write(target["ip"])
            f_t.write(os.linesep)
            f_t.close()
    
        # configure scanners
        cscan_config = {}
        for scanner in config["config"]:
            profile = config["config"][scanner]["profile"]
            if scanner == "w3af":
                cscan_config["CS_W3AF"] = "/root/w3af/w3af_api"
                if profile == "fast_scan":
                    cscan_config["CS_W3AF_PROFILE"] = "/root/w3af/profiles/fast_scan.pw3af"
                else:
                    raise UnsupportedProfileException()
                # params = config["config"][scanner]["parameters"]
            elif scanner == "zap":
                cscan_config["CS_ZAP"] = "/root/ZAP_2.7.0/zap.sh"
                if profile != "basic":
                    raise UnsupportedProfileException()
            else:
                raise UnsupportedScannerException()
        
        with open("/root/cscan/config.py", "w") as f_csconf:
            f_csconf.write("config = %s\n" % cscan_config)
    
    class UnsupportedProfileException(Exception):
        pass
    
    class UnsupportedScannerException(Exception):
        pass
    
    if __name__ == "__main__":
        main()