Skip to content

Commit

Permalink
Merge pull request #22 from HarryLudemann/Converting-to-tree
Browse files Browse the repository at this point in the history
Converting to tree structure for plugins
  • Loading branch information
HarryLudemann authored Nov 11, 2021
2 parents f9e31e7 + 4ffcbb8 commit 2990a92
Show file tree
Hide file tree
Showing 16 changed files with 299 additions and 68 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ Within the configuration folder contains a config.json as shown below, fill in A
#### 3. Run
Run the main.py script, which will bring you to the following:
```
_ _ _
| | | | | |
| |_| | __ _ __________ _| |__
| _ |/ _` |_ /_ / _` | '_ \
| | | | (_| |/ / / / (_| | | | |
\_| |_/\__,_/___/___\__,_|_| |_|
_ _ _
| \ | | | |
| \| | __ _ ___ | |_ ___
| . ` |/ _` |/ _ \| __/ _ \
| |\ | (_| | (_) | || (_) |
|_| \_|\__, |\___/ \__\___/
__/ |
|___/
Workplace: None
Expand All @@ -73,10 +75,10 @@ pip install ngoto
```
#### 2. Import and Initialize:
```python
from ngoto import ngoto # import the osint class from the hazzah module
from ngoto import Module # import the osint class from the hazzah module

# initialize the osint class and set my desired functions API's keys (Below are fake API keys)
hz = ngoto.Module()
hz = Module()
```
#### 3. Example Calling Functions:
```python
Expand Down
2 changes: 2 additions & 0 deletions configuration/plugin/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Plugin(Plugin):
name = 'Email'
version = 0.1
description = 'Search Email'

def get_info(self, target_email, api_key):
r = requests.get(f'https://emailverification.whoisxmlapi.com/api/v1?apiKey={api_key}&emailAddress=' + target_email ).json()
Expand Down
2 changes: 2 additions & 0 deletions configuration/plugin/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class Plugin(Plugin):
name = 'Google'
version = 0.1
description = 'Google Search'

def get_info(self, query, types, parameter, max_results=10):
""" given query, list of websites eg ['twitter.com', 'facebook.com'] or ['pdf', 'xlsx] and parameter eg filetype: or site:
Expand Down
2 changes: 2 additions & 0 deletions configuration/plugin/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Plugin(Plugin):
name = 'IP'
version = 0.1
description = 'Search IP'

def get_info(self, target_ip, IP_QUALITY_API_KEY):
r = requests.get('http://ip-api.com/json/' + target_ip ).json()
Expand Down
2 changes: 2 additions & 0 deletions configuration/plugin/phone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Plugin(Plugin):
name = 'Phone'
version = 0.1
description = 'Search Phone'

def get_info(self, target_phone, NUM_VERIFY_API_KEY):
r = requests.get(f"http://apilayer.net/api/validate?access_key={NUM_VERIFY_API_KEY}&number={target_phone } ").json()
Expand Down
62 changes: 62 additions & 0 deletions configuration/plugin/test/google2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from ngoto import Plugin
import logging
try:
from googlesearch import search
except ImportError:
logging.warning("No module named 'google' found, cannot use google dorking/search")

class Plugin(Plugin):
name = 'Google2'
version = 0.1
description = 'Google Search'

def get_info(self, query, types, parameter, max_results=10):
""" given query, list of websites eg ['twitter.com', 'facebook.com'] or ['pdf', 'xlsx] and parameter eg filetype: or site:
returns list of url's """
if not types: # if types is empty
logging.error('types var must contain list of requested file types')
return []
else:
formatted_query = f"\"{query}\" {parameter}{types[0]}"
for type in types[1:]: # iterate skipping first item
formatted_query += f" OR {parameter}{type}"
return { 'urls': search(formatted_query, num_results=max_results, lang="en" ) }

def main(self, hz):
type = hz.interface.get_input("Search f:file or w:website: ", '[Google]', hz.current_pos)
if type == 'back': return {}
target = hz.interface.get_input("Enter query: ", '[Google]', hz.current_pos)
if target == 'back': return {}
if type == 'f':
files = hz.interface.get_input("Enter file types eg. pdf xlsx docx: ", '[Google]', hz.current_pos).split()
if files == 'back': return {}
maxcount = hz.interface.get_input("Optionally enter max results: ", '[Google]', hz.current_pos)
if maxcount == 'back': return {}
return self.get_info(target, files, 'filetype:', int(maxcount))
elif type == 'w':
websites = hz.interface.get_input("Enter websites eg facebook.com twitter.com: ", '[Google]', hz.current_pos).split()
if websites == 'back': return {}
maxcount = hz.interface.get_input("Optionally enter max results: ", '[Google]', hz.current_pos)
if maxcount == 'back': return {}
return self.get_info(target, websites, 'site:', int(maxcount))

def get_context(self, args):
return self.get_info(args[0], args[1], args[2], args[3])

def print_info(self, hz, context, tables):
col_names = ['URL']
col_values = []
longest_url = 0
for item in context['urls']:
col_values.append( [item] )
if len(item) > longest_url:
longest_url = len(item)
col_widths = [longest_url]
hz.interface.output( '\n' + tables.get_table(col_names, col_widths, col_values) )

def create_table(self):
return '''
CREATE TABLE IF NOT EXISTS google (
id integer PRIMARY KEY AUTOINCREMENT,
url text );
'''
63 changes: 63 additions & 0 deletions configuration/plugin/test/test2/google3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from sys import version
from ngoto import Plugin
import logging
try:
from googlesearch import search
except ImportError:
logging.warning("No module named 'google' found, cannot use google dorking/search")

class Plugin(Plugin):
name = 'Google3'
version = 0.1
description = 'Google Search'

def get_info(self, query, types, parameter, max_results=10):
""" given query, list of websites eg ['twitter.com', 'facebook.com'] or ['pdf', 'xlsx] and parameter eg filetype: or site:
returns list of url's """
if not types: # if types is empty
logging.error('types var must contain list of requested file types')
return []
else:
formatted_query = f"\"{query}\" {parameter}{types[0]}"
for type in types[1:]: # iterate skipping first item
formatted_query += f" OR {parameter}{type}"
return { 'urls': search(formatted_query, num_results=max_results, lang="en" ) }

def main(self, hz):
type = hz.interface.get_input("Search f:file or w:website: ", '[Google]', hz.current_pos)
if type == 'back': return {}
target = hz.interface.get_input("Enter query: ", '[Google]', hz.current_pos)
if target == 'back': return {}
if type == 'f':
files = hz.interface.get_input("Enter file types eg. pdf xlsx docx: ", '[Google]', hz.current_pos).split()
if files == 'back': return {}
maxcount = hz.interface.get_input("Optionally enter max results: ", '[Google]', hz.current_pos)
if maxcount == 'back': return {}
return self.get_info(target, files, 'filetype:', int(maxcount))
elif type == 'w':
websites = hz.interface.get_input("Enter websites eg facebook.com twitter.com: ", '[Google]', hz.current_pos).split()
if websites == 'back': return {}
maxcount = hz.interface.get_input("Optionally enter max results: ", '[Google]', hz.current_pos)
if maxcount == 'back': return {}
return self.get_info(target, websites, 'site:', int(maxcount))

def get_context(self, args):
return self.get_info(args[0], args[1], args[2], args[3])

def print_info(self, hz, context, tables):
col_names = ['URL']
col_values = []
longest_url = 0
for item in context['urls']:
col_values.append( [item] )
if len(item) > longest_url:
longest_url = len(item)
col_widths = [longest_url]
hz.interface.output( '\n' + tables.get_table(col_names, col_widths, col_values) )

def create_table(self):
return '''
CREATE TABLE IF NOT EXISTS google (
id integer PRIMARY KEY AUTOINCREMENT,
url text );
'''
2 changes: 2 additions & 0 deletions configuration/plugin/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

class Plugin(Plugin):
name = 'URL'
version = 0.1
description = 'Search URL'

def get_info(self, target_url):
""" Given target URL returns urls ip
Expand Down
8 changes: 3 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# this script is to launch the command line tool
import logging
import traceback
from os.path import exists # check config file exists
import ngoto

from ngoto import CLT

if __name__ == '__main__':
hz = ngoto.CLT()
hz = CLT()
try:
hz.load_config()
hz.clearConsole()
hz.interface.options(hz)
hz.interface.options(hz.current_workplace, hz.root)
hz.main()
except Exception as e:
print(f"{hz.interface.bcolors.ENDC}")
Expand Down
2 changes: 1 addition & 1 deletion ngoto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from ngoto.main import Ngoto, CLT, Module
from ngoto.utilities import Plugin, Workplace, Table
from ngoto.utilities import Plugin, Workplace, Table, Node
Loading

0 comments on commit 2990a92

Please sign in to comment.