Skip to content

Commit

Permalink
Added support to automatically configure settings by loading a config…
Browse files Browse the repository at this point in the history
…uration file
  • Loading branch information
Marco Lancini committed Feb 5, 2019
1 parent 26d18c8 commit b47570f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).



## [2.3]
## [2.3] - 2019-02-05
#### Added
- Support to automatically configure settings by loading a configuration file
#### Fixed
- Nmap output file names when running concurrently on all targets

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ GoScan supports all the main steps of network enumeration:

![process](https://raw.githubusercontent.com/marco-lancini/goscan/master/.github/goscan_process.png)


| Step | Commands |
| ---- | ----------- |
| 1. **Load targets** | <ul><li>Add a single target via the CLI (must be a /32): `load target SINGLE <IP>`</li><li>Upload multiple targets from a text file or folder: `load target MULTI <path-to-file>`</li></ul>|
| 1. **Load targets** | <ul><li>Add a single target via the CLI (must be a valid CIDR): `load target SINGLE <IP/32>`</li><li>Upload multiple targets from a text file or folder: `load target MULTI <path-to-file>`</li></ul>|
| 2. **Host Discovery** | <ul><li>Perform a Ping Sweep: `sweep <TYPE> <TARGET>`</li><li> Or load results from a previous discovery:<ul><li>Add a single alive host via the CLI (must be a /32): `load alive SINGLE <IP>`</li><li>Upload multiple alive hosts from a text file or folder: `load alive MULTI <path-to-file>`</li></ul></li></ul> |
| 3. **Port Scanning** | <ul><li>Perform a port scan: `portscan <TYPE> <TARGET>`</li><li>Or upload nmap results from XML files or folder: `load portscan <path-to-file>`</li></ul> |
| 4. **Service Enumeration** | <ul><li>Dry Run (only show commands, without performing them): `enumerate <TYPE> DRY <TARGET>`</li><li> Perform enumeration of detected services: `enumerate <TYPE> <POLITE/AGGRESSIVE> <TARGET>`</li></ul> |
| 5. **Special Scans** | <ul><li>*EyeWitness*<ul><li>Take screenshots of websites, RDP services, and open VNC servers (KALI ONLY): `special eyewitness`</li><li>`EyeWitness.py` needs to be in the system path</li></ul></li><li>*Extract (Windows) domain information from enumeration data*<ul><li>`special domain <users/hosts/servers>`</li></ul></li><li>*DNS*<ul><li>Enumerate DNS (nmap, dnsrecon, dnsenum): `special dns DISCOVERY <domain>`</li><li>Bruteforce DNS: `special dns BRUTEFORCE <domain>`</li><li>Reverse Bruteforce DNS: `special dns BRUTEFORCE_REVERSE <domain> <base_IP>`</li></ul></li> |
| **Utils** | <ul><li>Show results: `show <targets/hosts/ports`</li><li>Change the output folder (by default `~/goscan`): `set output_folder <PATH>`</li><li>Modify the default nmap switches: `set nmap_switches <SWEEP/TCP_FULL/TCP_STANDARD/TCP_VULN/UDP_STANDARD> <SWITCHES>`</li><li>Modify the default wordlists: `set_wordlists <FINGER_USER/FTP_USER/...> <PATH>`</li></ul> |

| **Utils** | <ul><li>Show results: `show <targets/hosts/ports>`</li><li>Automatically configure settings by loading a config file: `set config_file <PATH>`</li><li>Change the output folder (by default `~/goscan`): `set output_folder <PATH>`</li><li>Modify the default nmap switches: `set nmap_switches <SWEEP/TCP_FULL/TCP_STANDARD/TCP_VULN/UDP_STANDARD> <SWITCHES>`</li><li>Modify the default wordlists: `set_wordlists <FINGER_USER/FTP_USER/...> <PATH>`</li></ul> |



Expand Down
3 changes: 3 additions & 0 deletions goscan/core/cli/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func argumentsCompleter(d prompt.Document, args []string) []prompt.Suggest {
case "set":
if len(args) == 2 {
subcommands := []prompt.Suggest{
{Text: "config_file", Description: "Set configs from file."},
{Text: "output_folder", Description: "Set the output folder."},
{Text: "nmap_switches", Description: "Modify the default nmap switches."},
{Text: "wordlists", Description: "Modify the default wordlists."},
Expand All @@ -79,6 +80,8 @@ func argumentsCompleter(d prompt.Document, args []string) []prompt.Suggest {
}
if len(args) == 3 {
switch args[1] {
case "config_file":
return fileCompleter(d)
case "output_folder":
return fileCompleter(d)
case "nmap_switches":
Expand Down
24 changes: 24 additions & 0 deletions goscan/core/cli/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func cmdHelp() {
[]string{"Show", "Show live hosts", "show hosts"},
[]string{"Show", "Show detailed ports information", "show ports"},

[]string{"Utils", "Set configs from file", "set config_file <PATH>"},
[]string{"Utils", "Set output folder", "set output_folder <PATH>"},
[]string{"Utils", "Modify the default nmap switches", "set nmap_switches <SWEEP/TCP_FULL/TCP_STANDARD/TCP_VULN/UDP_STANDARD> <SWITCHES>"},
[]string{"Utils", "Modify the default wordlists", "set wordlists <FINGER_USER/FTP_USER/...> <PATH>"},
Expand Down Expand Up @@ -414,6 +415,26 @@ func ShowPorts() {
// ---------------------------------------------------------------------------------------
// UTILS
// ---------------------------------------------------------------------------------------
// Set configs from file
func SetConfigFile(fname string) {
// Open source file
file, err := os.Open(fname)
if err != nil {
utils.Config.Log.LogError(fmt.Sprintf("Error while reading source file (%s): %s", fname, err))
}
defer file.Close()
// Read line by line
scanner := bufio.NewScanner(file)
for scanner.Scan() {
cmd := scanner.Text()
Executor(cmd)
}
// Error while reading the file
if err := scanner.Err(); err != nil {
utils.Config.Log.LogError(fmt.Sprintf("Error while reading source file: %s", err))
}
}

func cmdSet(args []string) {
// // Check arguments length to ensure all required options have been provided
// if len(args) != 1 {
Expand All @@ -424,6 +445,9 @@ func cmdSet(args []string) {
// Parse kind of operation
kind, args := utils.ParseNextArg(args)
switch kind {
case "config_file":
fname, _ := utils.ParseNextArg(args)
SetConfigFile(fname)
case "output_folder":
folder, _ := utils.ParseNextArg(args)
utils.ChangeOutFolder(folder)
Expand Down
1 change: 0 additions & 1 deletion goscan/core/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func ChangeOutFolder(path string) {
}



// ---------------------------------------------------------------------------------------
// MANAGE COMMANDS
// ---------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions goscan/sample_config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set output_folder ~/goscan/
set nmap_switches SWEEP -v -n -sn -PE -PP -PM -PS22,2222,80,8080,443,113,3389,445 -PA22,2222,80,8080,443,113,3389,445

0 comments on commit b47570f

Please sign in to comment.