Skip to content
74 changes: 37 additions & 37 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ At the first, you must send an API key through the request each time you send a
>>> import requests
>>> from requests.packages.urllib3.exceptions import InsecureRequestWarning
>>> requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
>>> r = requests.get('https://127.0.0.1:5000/?key=8370bd0a0b9a98ac25b341833fb0fb07')
>>> r = requests.get('https://127.0.0.1:5000/?key=8370bd0a0b9a98ac25b341833fb0fb07', verify=False)
>>> r.status_code
200
>>> r = requests.post('https://127.0.0.1:5000/', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> r = requests.post('https://127.0.0.1:5000/', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"}, verify=False)
>>> r.status_code
200
>>> r = requests.get('https://127.0.0.1:5000/', cookies={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> r = requests.get('https://127.0.0.1:5000/', cookies={"key": "8370bd0a0b9a98ac25b341833fb0fb07"}, verify=False)
>>> r.status_code
200
>>> r = requests.get('https://127.0.0.1:5000/new/scan', cookies={"key": "wrong_key"})
>>> r = requests.get('https://127.0.0.1:5000/new/scan', cookies={"key": "wrong_key"}, verify=False)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
>>> r.status_code
401
```
Expand All @@ -75,11 +75,11 @@ At the first, you must send an API key through the request each time you send a
To submit a new scan follow this step.

```python
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1,owasp.org", "selected_modules": "port_scan", "report_path_filename": "/home/test.html"})
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07", "targets": "127.0.0.1,owasp.org", "selected_modules": "port_scan", "report_path_filename": "/home/test.html"}, verify=False)
>>> r.status_code
200
>>> import json
>>> print json.dumps(json.loads(r.content), sort_keys=True, indent=4)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
{
"backup_ports": null,
"check_ranges": false,
Expand Down Expand Up @@ -123,16 +123,16 @@ To submit a new scan follow this step.
Please note, `targets` and `selected_modules` are **necessary** to submit a new scan unless you modify the config file before! The `selected_modules` could be empty if you define the `profile`.

```python
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"})
>>> r.content
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "8370bd0a0b9a98ac25b341833fb0fb07"}, verify=False)
>>> r.content.decode('utf-8')
'{"msg":"Cannot specify the target(s)","status":"error"}\n'

>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1"})
>>> r.content
u'{"msg":"please choose your scan method!","status":"error"}\n'
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1"}, verify=False)
>>> r.content.decode('utf-8')
'{"msg":"please choose your scan method!","status":"error"}\n'

>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1", "selected_modules": "dir_scan,port_scan", "report_path_filename": "/home/test.html"})
>>> print json.dumps(json.loads(r.content), sort_keys=True, indent=4)
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1", "selected_modules": "dir_scan,port_scan", "report_path_filename": "/home/test.html"}, verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
{
"backup_ports": null,
"check_ranges": false,
Expand Down Expand Up @@ -172,8 +172,8 @@ u'{"msg":"please choose your scan method!","status":"error"}\n'
"users": null,
"verbose_level": 0
}
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1", "profile": "information_gathering"})
>>> print json.dumps(json.loads(r.content), sort_keys=True, indent=4)
>>> r = requests.post('https://127.0.0.1:5000/new/scan', data={"key": "09877e92c75f6afdca6ae61ad3f53727", "targets": "127.0.0.1", "profile": "information_gathering"}, verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
{
"backup_ports": null,
"check_ranges": false,
Expand Down Expand Up @@ -227,16 +227,16 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow

```python
>>> s = requests.session()
>>> r = s.get("https://localhost:5000/session/set?key=09877e92c75f6afdca6ae61ad3f53727")
>>> print json.dumps(json.loads(r.content), sort_keys=True, indent=4)
>>> r = s.get("https://localhost:5000/session/set?key=09877e92c75f6afdca6ae61ad3f53727", verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
{
"msg": "your browser session is valid",
"status": "ok"
}
>>> print r.cookies
>>> print(r.cookies)
<RequestsCookieJar[<Cookie key=09877e92c75f6afdca6ae61ad3f53727 for localhost.local/>]>
>>> r = s.get("https://localhost:5000/new/scan")
>>> print r.content
>>> r = s.get("https://localhost:5000/new/scan", verify=False)
>>> print(r.content.decode('utf-8'))
{
"msg": "Cannot specify the target(s)",
"status": "error"
Expand All @@ -247,8 +247,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow
### Check Cookie

```python
>>> r = s.get("https://localhost:5000/session/check")
>>> print r.content
>>> r = s.get("https://localhost:5000/session/check", verify=False)
>>> print(r.content.decode('utf-8'))
{
"msg": "your browser session is valid",
"status": "ok"
Expand All @@ -257,23 +257,23 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow
### UnSet Cookie

```python
>>> r = s.get("https://localhost:5000/session/kill")
>>> print r.content
>>> r = s.get("https://localhost:5000/session/kill", verify=False)
>>> print(r.content.decode('utf-8'))
{
"msg": "your browser session killed",
"status": "ok"
}

>>> print r.cookies
>>> print(r.cookies)
<RequestsCookieJar[]>
>>>
```

## Results List

```python
>>> r = s.get("https://localhost:5000/results/get_list?page=1")
>>> print(json.dumps(json.loads(r.content), sort_keys=True, indent=4))
>>> r = s.get("https://localhost:5000/results/get_list?page=1", verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
[
{
"api_flag": 0,
Expand Down Expand Up @@ -417,8 +417,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow
### Get a Scan Result

```python
>>> r = s.get("https://localhost:5000/results/get?id=8")
>>> print r.content[:500]
>>> r = s.get("https://localhost:5000/results/get?id=8", verify=False)
>>> print(r.content.decode('utf-8')[:500])
<!DOCTYPE html>
<!-- THIS PAGE COPIED AND MODIFIED FROM http://bl.ocks.org/robschmuecker/7880033-->
<title>OWASP Nettacker Report</title>
Expand Down Expand Up @@ -450,8 +450,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow

## Hosts List
```python
>>> r = s.get("https://localhost:5000/logs/search?q=&page=1")
>>> print json.dumps(json.loads(r.content), sort_keys=True, indent=4)
>>> r = s.get("https://localhost:5000/logs/search?q=&page=1", verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
[
{
"host": "owasp.org",
Expand Down Expand Up @@ -479,8 +479,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow
### Search in the Hosts

```python
>>> r = s.get("https://localhost:5000/logs/search?q=port_scan&page=3")
>>> print r.content
>>> r = s.get("https://localhost:5000/logs/search?q=port_scan&page=3", verify=False)
>>> print(r.content.decode('utf-8'))
[
{
"host": "owasp4.owasp.org",
Expand Down Expand Up @@ -665,8 +665,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow
```
## Generate a HTML Scan Result for a Host
```python
>>> r = s.get("https://localhost:5000/logs/get_html?target=127.0.0.1&key=<your_api_key>")
>>> print r.content[:1000]
>>> r = s.get("https://localhost:5000/logs/get_html?target=127.0.0.1&key=<your_api_key>", verify=False)
>>> print(r.content.decode('utf-8')[:1000])
<!DOCTYPE html>
<!-- THIS PAGE COPIED AND MODIFIED FROM http://bl.ocks.org/robschmuecker/7880033-->
<title>OWASP Nettacker Report</title>
Expand Down Expand Up @@ -706,8 +706,8 @@ To enable session-based requests, like (e.g. Python `requests.session()` or brow

### Get the Scan Result in JSON Type
```python
>>> r = s.get("https://localhost:5000/logs/get_json?target=owasp.org&key=<your_api_key>")
>>> print(json.dumps(json.loads(r.content), sort_keys=True, indent=4))
>>> r = s.get("https://localhost:5000/logs/get_json?target=owasp.org&key=<your_api_key>", verify=False)
>>> print(json.dumps(json.loads(r.content.decode('utf-8')), sort_keys=True, indent=4))
[
{
"DESCRIPTION": "443/http/TCP_CONNECT",
Expand Down