-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from HarryLudemann/Converting-to-tree
Converting to tree structure for plugins
- Loading branch information
Showing
16 changed files
with
299 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.