Skip to content
Ali Razmjoo edited this page Apr 20, 2018 · 19 revisions

API

WebUI/API Manual usage explained in the Usage page but let's get into the requests structure now.

Porpuse

API usage purposes depend on the users, Some of them may want to scan their local company to monitor the network, This feature let all security staff use OWASP Nettacker on a shared server safely (You may enable the HTTPS).

Requests Structure

C:\Users\Zombie\Documents\GitHub\OWASP-Nettacker>python nettacker.py --start-api

   ______          __      _____ _____
  / __ \ \        / /\    / ____|  __ \
 | |  | \ \  /\  / /  \  | (___ | |__) |
 | |  | |\ \/  \/ / /\ \  \___ \|  ___/
 | |__| | \  /\  / ____ \ ____) | |     Version 0.0.1
  \____/   \/  \/_/    \_\_____/|_|     SAME
                          _   _      _   _             _
                         | \ | |    | | | |           | |
  github.com/viraintel   |  \| | ___| |_| |_ __ _  ___| | _____ _ __
  owasp.org              | . ` |/ _ \ __| __/ _` |/ __| |/ / _ \ '__|
  viraintel.com          | |\  |  __/ |_| || (_| | (__|   <  __/ |
                         |_| \_|\___|\__|\__\__,_|\___|_|\_\___|_|



 * API Key: 8370bd0a0b9a98ac25b341833fb0fb07
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

At the first, you must send API key through the request each time you send a request in GET, POST or Cookies in the value named key or you will get 401 error in the restricted area.

>>> import requests
>>> r = requests.get('http://127.0.0.1:5000/?key=8370bd0a0b9a98ac25b341833fb0fb07')
>>> r.status_code
200
>>> r = requests.post('http://127.0.0.1:5000/', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> r.status_code
200
>>> r = requests.get('http://127.0.0.1:5000/', cookies={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> r.status_code
200
>>> r = requests.get('http://127.0.0.1:5000/new/scan', cookies={"key": "wrong_key"})
>>> r.status_code
401

New Scan

To submit a new scan follow this step.

>>> r = requests.post('http://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1,owasp.org", "scan_method": "port_scan"})
>>> r.status_code
200
{
  "api_db_name": "C:\\Users\\Zombie/.owasp-nettacker/database.sqlite3",
  "backup_ports": null,
  "check_ranges": false,
  "check_subdomains": false,
  "graph_flag": "d3_tree_v2_graph",
  "home_path": "C:\\Users\\Zombie/.owasp-nettacker",
  "language": "en",
  "log_in_file": "C:\\Users\\Zombie/.owasp-nettacker/results/results_2018_04_20_22_59_38_rqfnmizxji.html",
  "methods_args": {
    "as_user_set": "set_successfully"
  },
  "passwds": null,
  "ping_flag": false,
  "ports": null,
  "profile": null,
  "results_path": "C:\\Users\\Zombie/.owasp-nettacker/results",
  "retries": 3,
  "scan_method": [
    "dir_scan",
    "port_scan"
  ],
  "socks_proxy": null,
  "targets": [
    "127.0.0.1"
  ],
  "thread_number": 100,
  "thread_number_host": 30,
  "time_sleep": 0.0,
  "timeout_sec": 3,
  "tmp_path": "C:\\Users\\Zombie/.owasp-nettacker/tmp",
  "users": null,
  "verbose_level": 0
}

>>>

Plese note, targets and scan_method are necessary to submit a new scan unless you modify the config file before! The scan_method could be empty if you define the profile.

>>> r = requests.post('http://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> print r.content
{
  "msg": "Cannot specify the target(s)",
  "status": "error"
}

>>> r = requests.post('http://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1"})
>>> print r.content
{
  "msg": "please choose your scan method!",
  "status": "error"
}

>>> r = requests.post('http://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1", "scan_method": "dir_scan,port_scan"})
>>> print r.content
{
  "api_db_name": "C:\\Users\\Zombie/.owasp-nettacker/database.sqlite3",
  "backup_ports": null,
  "check_ranges": false,
  "check_subdomains": false,
  "graph_flag": "d3_tree_v2_graph",
  "home_path": "C:\\Users\\Zombie/.owasp-nettacker",
  "language": "en",
  "log_in_file": "C:\\Users\\Zombie/.owasp-nettacker/results/results_2018_04_20_23_00_38_hnlhuvobom.html",
  "methods_args": {
    "as_user_set": "set_successfully"
  },
  "passwds": null,
  "ping_flag": false,
  "ports": null,
  "profile": null,
  "results_path": "C:\\Users\\Zombie/.owasp-nettacker/results",
  "retries": 3,
  "scan_method": [
    "dir_scan",
    "port_scan"
  ],
  "socks_proxy": null,
  "targets": [
    "127.0.0.1"
  ],
  "thread_number": 100,
  "thread_number_host": 30,
  "time_sleep": 0.0,
  "timeout_sec": 3,
  "tmp_path": "C:\\Users\\Zombie/.owasp-nettacker/tmp",
  "users": null,
  "verbose_level": 0
}

>>> r = requests.post('http://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1", "profile": "information_gathering"})
>>> print r.content
{
  "api_db_name": "C:\\Users\\Zombie/.owasp-nettacker/database.sqlite3",
  "backup_ports": null,
  "check_ranges": false,
  "check_subdomains": false,
  "graph_flag": "d3_tree_v2_graph",
  "home_path": "C:\\Users\\Zombie/.owasp-nettacker",
  "language": "en",
  "log_in_file": "C:\\Users\\Zombie/.owasp-nettacker/results/results_2018_04_20_23_01_01_eahnqpwosz.html",
  "methods_args": {
    "as_user_set": "set_successfully"
  },
  "passwds": null,
  "ping_flag": false,
  "ports": null,
  "profile": "information_gathering",
  "results_path": "C:\\Users\\Zombie/.owasp-nettacker/results",
  "retries": 3,
  "scan_method": [
    "port_scan"
  ],
  "socks_proxy": null,
  "targets": [
    "127.0.0.1"
  ],
  "thread_number": 100,
  "thread_number_host": 30,
  "time_sleep": 0.0,
  "timeout_sec": 3,
  "tmp_path": "C:\\Users\\Zombie/.owasp-nettacker/tmp",
  "users": null,
  "verbose_level": 0
}

>>>

All variables in JSON you've got in results could be changed in GET/POST/Cookies, you can fill them all just like normal CLI commands. (e.g. same scan method name (modules), you can separate with ,, you can use ports like 80,100-200,1000,2000, set users and passwds user1,user2, passwd1,passwd2). You cannot use read_from_file:/tmp/users.txt syntax in methods_args. if you want to send a big password list, just send it through the POST requests and separated with ,.