Skip to content

Commit de3cfa2

Browse files
committed
backup before readding sql
1 parent a838885 commit de3cfa2

File tree

15 files changed

+1565
-806
lines changed

15 files changed

+1565
-806
lines changed

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ postgres = "0.19.3"
1414
openssl = "0.10.38"
1515
postgres-openssl = "0.5.0"
1616
chrono = "0.4"
17-
clap = "4.0.9"
17+
clap = { version = "4.0.9", features = ["unstable-grouped"] }
1818
toml = "0.5.9"
1919
strip-ansi-escapes = "0.1.1"
2020
prettytable-rs = "^0.9"
21-
dns-lookup = "1.0.8"
21+
# dns-lookup = "1.0.8"
22+
reqwest = { version = "0.11", features = ["blocking"] }
23+
serde_json = "1.0"

TODOs.md

Lines changed: 42 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,72 @@
1-
# TODOs:
1+
# TODOs
2+
23
---
34
a list of todos.
45

56
## Active
6-
- [ ] add interpretation of pipes to command get_cmd() (ie. if something gets piped into a command that can be parsed, parse the output based the program getting piped into.)
77

8+
- [ ] add interpretation of pipes to command get_cmd() (ie. if something gets piped into a command that can be parsed, parse the output based the program getting piped into.)
89
- [ ] make the python parsers use objects to output data and make the objects printable via, `__str__(self)`
10+
- [x] base_nmap.py
11+
- [ ] feroxbuster
12+
- [ ] gobuster
13+
- [ ] fping
14+
- [ ] hydra
15+
- [ ] dig
16+
- [ ] john
17+
- [ ] john_show
18+
- [ ] rustscan
919

1020
- [x] add an exit status column to the commands table. (this would allow me to only parse certain commands with they exit successfully and not parse commands like ffuf or wfuzz if the user exits the command prematurely bc they're changing parameters and command line arguments.)
11-
1221
- [x] update install instructions
13-
1422
- [ ] write documentation.
15-
1623
- [x] allow each engagement file to declare its own sql-server conf? (not sure if i wanna do this one.) (i did it.)
17-
1824
- [ ] add listing of engagements.
19-
2025
- [ ] clear out old TODOS. :P (there are many old TODOs in the [cleared](#Cleared) section that date back to the beginning of the project) (they give me motivation but they also clutter this file.)
21-
2226
- [ ] flush out client and server terminal args.
23-
2427
- [ ] test client server mode.
25-
2628
- [x] add `SELECT DISTINCT` to the SQL queries generated by command line arguments.
27-
- [x] add `DISTINCT` to the query generator.
28-
- [x] ignore `DISTINCT` key word when generating the list of columns selected.
29-
29+
- [x] add `DISTINCT` to the query generator.
30+
- [x] ignore `DISTINCT` key word when generating the list of columns selected.
3031
- [x] add `SELECT TOP` to the keyword generator
31-
- [x] ignore the `TOP` keyword.
32-
- [x] skip the next token (the number).
33-
32+
- [x] ignore the `TOP` keyword.
33+
- [x] skip the next token (the number).
3434
- [ ] improve the dig parser.
35-
- [ ] change understanding of the difference between ipv4 and ipv6 to be based on record type ('A' vs 'AAAA').
36-
- [ ] add 'CNAME' parsing.
37-
35+
- [ ] change understanding of the difference between ipv4 and ipv6 to be based on record type ('A' vs 'AAAA').
36+
- [ ] add 'CNAME' parsing.
3837
- [ ] ~~do [this](https://www.codegrepper.com/code-examples/whatever/sed+remove+ansi+color+codes) instead of using the strip_ansi_escape crate.~~ even better, do it per parser in python using regex. (the crate removes tabs inserted by ANSI as well.)
39-
4038
- [ ] write a dog parser. (dog is like dig but simpler, and more elegant imo).
41-
42-
- [ ] move the removal of ANSI control codes to the python parsers bc not all parsers need it and it was interfearing with some parsers.
43-
- [ ] find a python module that can strip ANSI control codes (only the color codes).
44-
- [ ] remove from the rust code.
45-
- [ ] add to the python parsers where its important.
46-
- [ ] add to feroxbuster.py
47-
- [ ] add to rustscan.py
48-
39+
- [ ] move the removal of ANSI control codes to the python parsers bc not all parsers need it and it was interfearing with some parsers. ~~(or maybe add a config option to only strip ansi on certain parsers).~~
40+
- [ ] find a python module that can strip ANSI control codes (only the color codes).
41+
- [ ] remove from the rust code.
42+
- [ ] add to the python parsers where its important.
43+
- [ ] add to feroxbuster.py
44+
- [ ] add to rustscan.py
4945
- [ ] switch to DGraph back end
50-
- [x] make the dgraph schema
51-
52-
- [ ] figure out how to segregate engagements.
53-
54-
- [ ] figure out a clean way to add each entity to the database (and write a GraphQL file to do it)
55-
56-
- [x] figure out how to add the data.
57-
58-
- [ ] change parsers to output json/RDF that can be parsed and sent to the server. for example the nmap parser run against the command `nmap youtube.com` might output something like: ~~~
59-
60-
~~~json
61-
[
62-
{
63-
"uid": "_:dns_name_0",
64-
"type": "DNSName",
65-
...
66-
"machine": "_:machine_0"
67-
},
68-
{
69-
"uid": "_:machine_0"
70-
"type": "Machine",
71-
...
72-
"ports": ["_:port_0", "_:port_1"],
73-
"dns_name": "_:dns_name_0"
74-
},
75-
{
76-
"uid": "_:port_0",
77-
"type": "Port",
78-
...
79-
"machine": "_:machine_0"
80-
},
81-
{
82-
"uid": "_:port_1",
83-
"type": "Port",
84-
...
85-
"machine": "_:machine_0"
86-
}
87-
]
88-
~~~
89-
90-
- [ ] add adding of parser data in an idempotent way.
91-
92-
- [ ] figure out a clean way to modify any entity to the database (and write a GraphQL file to do it)
93-
94-
- [ ] figure out querying from rust (in either DQL (Dgraph Query Language) or GraphQL)
95-
96-
- [ ] remove all the SQL specific stuff from the config files
97-
98-
- [ ] make feroxbuster and gobuster parsers output the a host, which points to the a DNSNames node.
46+
- [x] make the dgraph schema
47+
- [ ] figure out how to segregate engagements.
48+
- [ ] add an engagement type. that stores a list of each type used in dgraph and search based on that presence in the engagement type with a given name.
49+
- [x] figure out a clean way to add each entity to the database (and write a GraphQL file to do it)
9950

51+
- [x] figure out how to add the data.
52+
- [x] change parsers to also output a uid and the things its connected to.
53+
54+
- [x] add adding of parser data in an idempotent way.
55+
- [ ] figure out a clean way to modify any entity to the database (and write a GraphQL file to do it)
56+
- [ ] figure out querying from rust (in either DQL (Dgraph Query Language) or GraphQL)
57+
- [ ] remove all the SQL specific stuff from the config files
58+
- [ ] make feroxbuster and gobuster parsers output the a host, which points to the a DNSNames node.
59+
- [ ] bring back sql as an optional feature and allow the user to choose between dgraph and sql.
10060

10161
## Maybe Do/Future TODOs
62+
10263
- [] add date and time check to client and engagement conf. so it'll not process data before the start date and time. AND alert the user after the engagement is over. set the complete flag to true after the end date and time. (i think this will requires finding a new DateTime library)
10364
- [] ~~add optional IP address ranges to engagement conf. that way the program can check to see if the server is in scope. (maybe use nmap IP formatting) then the client can stop you from going out of scope by making a call in `preexec`~~ maybe much later on down the line.
10465
- [] ~~make numeric values numerically typed in the sql db~~ (not worth it at the time being)
10566
- [] ~~split up local_time column from commands database (on column for year, one for month, day, hour, min, and one fore the time zone offset.)~~ (not worth it at the time being. probably wont be worth it for a while tbh.)
10667

107-
10868
## Cleared
69+
10970
- [x] add an SQL file and a shell script to make the PostgreSQL db.
11071
- [x] add interaction with SQL
11172
- [x] add password configuration for SQL
@@ -125,11 +86,11 @@ a list of todos.
12586
- [x] fixed manual exec setting via cmd line args.
12687
- [x] add terminal based play/pause functionality.
12788
- [x] add a flag to query subcmd to query for then column names of the table.
128-
- [x] add multiple sql server configs
89+
- [x] add multiple sql server configs
12990
- [x] add subcmd to switch sql server configs (just like `engagement -a`). (achieved with `config -s`)
13091
- [x] split config into global and user configs.
13192
- [x] add `info` subcmd that will print information like: postgres server host, current engagement completeness, and active status (paused vs. actively parsing).
132-
- [x] give the `quiet_log` server config file param functionality.
93+
- [x] give the `quiet_log` server config file param functionality.
13394
- [x] fix get_cmd() issue where you can't pass arguments to sudo, time, doas, or proxychains. (this is particularly a problem with proxychains.)
13495
- [x] fix feroxbuster parser crashing when outputing help menu on empty args
135-
- [x] add a way to ignore parsers if the command contains the help args.
96+
- [x] add a way to ignore parsers if the command contains the help args.

configs/etc/ptdb/parsers/base_nmap.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
"""
33
nmap-parser.py
44
5-
parser for bassic nmap commands (NOT including vulnerability scans, (not yet at least))
5+
parser for basic nmap commands (NOT including vulnerability scans, (not yet at least))
66
77
8-
Author: Calacuda | MIT Licence | Epoch: Jul 30, 2022
8+
Author: Calacuda | MIT License | Epoch: Jul 30, 2022
99
1010
TODOs:
11-
- sometimes durring verison scans the ip adress gets used as the host name, not the ip
12-
adress. fix this.
11+
- sometimes during version scans the ip address gets used as the host name, not the ip
12+
address. fix this.
1313
-
1414
"""
1515

1616

1717
from sys import stdin
1818
import re
1919
import sys
20+
2021
folder = "/".join(__file__.split("/")[0:-1])
2122
sys.path.append(folder)
2223
from parser_output import ParserOutput
@@ -67,7 +68,7 @@ def get_ports(host):
6768
if m:
6869
p_dat = {}
6970
p_dat["port"] = m.group(1).strip()
70-
p_dat["TL_protocol"] = m.group(2).strip()
71+
p_dat["tl_protocol"] = m.group(2).strip()
7172
p_dat["state"] = m.group(3).strip()
7273
p_dat["service"] = m.group(4).strip()
7374
# p_dat["version"] = line[line.find(m.group(4).strip()) + len(m.group(4)):].strip()
@@ -124,7 +125,7 @@ def store_data(host):
124125
# print(dns_name)
125126
dns_name_uid = output_data.add_dns_name({"name": dns_name}, machine_uid=host_uid)
126127
# mod host data to include dns_name data
127-
output_data.mod_machine(host_uid, {"dns_name": dns_name_uid})
128+
output_data.mod_machine(host_uid, {"dns_names": dns_name_uid})
128129

129130

130131
def main(full_report):
@@ -143,6 +144,7 @@ def main(full_report):
143144

144145
# print(bytes(str(output_data), encoding="ascii"))
145146
print(output_data)
147+
# print(output_data.ports.keys())
146148

147149
if __name__ == "__main__":
148150
# print(main(stdin.readlines())[0:-1], end="")

configs/etc/ptdb/parsers/parser_output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def __str__(self):
1919
final = []
2020

2121
for things in [self.machines, self.dns_names, self.ports, self.credentials, self.web_dirs]:
22-
elms = []
2322
for entity in things.values():
23+
elms = []
2424
for var_name, val in entity.items():
2525
if type(val) == list:
2626
[elms.append(self.make_elm(var_name, tmp_val)) for tmp_val in val]
2727
else:
2828
elms.append(self.make_elm(var_name, val))
2929

30-
final.append(chr(0).join(elms))
30+
final.append(chr(0).join(elms))
3131

3232

3333
return "\n".join(final)

0 commit comments

Comments
 (0)