mirror of
https://github.com/Astatin3/Auto-Shodanner.git
synced 2026-06-08 16:18:09 -06:00
Add Scan Settings page, Work on saving data
TODO: - Finish saving data
This commit is contained in:
@@ -2,9 +2,10 @@ import libs.scanutils as scanutils
|
||||
mm = None
|
||||
|
||||
def dashboardMetrics(ac):
|
||||
ac.send('Scanner-Metrics', {
|
||||
"scanCount": scanutils.countScannedIps()
|
||||
})
|
||||
pass
|
||||
# ac.send('Scanner-Metrics', {
|
||||
# "scanCount": scanutils.countScannedIps()
|
||||
# })
|
||||
|
||||
def init(moduleMaster):
|
||||
global mm
|
||||
|
||||
+49
-12
@@ -9,7 +9,46 @@ def loadSettings(ac):
|
||||
|
||||
|
||||
def setSettings(ac, data):
|
||||
mm.vars['Scanner-Settings'] = data['data']
|
||||
if not mm.userInGroup(ac, 'Admins'):
|
||||
mm.sendPopupError(ac.rawClient, "Error", "You are not authorised")
|
||||
return
|
||||
|
||||
data = data['data']
|
||||
valid = True
|
||||
|
||||
valid = valid and isinstance(data['numJobs'], int)
|
||||
valid = valid and isinstance(data['maxPingTimeout'], int)
|
||||
valid = valid and isinstance(data['maxNmapTimeout'], int)
|
||||
valid = valid and isinstance(data['nmapGroupSize'], int)
|
||||
|
||||
valid = valid and isinstance(data['tcpSettings'], dict)
|
||||
valid = valid and isinstance(data['udpSettings'], dict)
|
||||
|
||||
valid = valid and isinstance(data['tcpSettings']['mode'], int)
|
||||
valid = valid and isinstance(data['udpSettings']['mode'], int)
|
||||
|
||||
if valid:
|
||||
for obj in [data['tcpSettings'], data['udpSettings']]:
|
||||
match obj['mode']:
|
||||
case -1:
|
||||
pass
|
||||
case 1:
|
||||
valid = valid and isinstance(obj['mode'], int)
|
||||
valid = valid and isinstance(obj['ports'], list)
|
||||
if valid:
|
||||
valid = valid and all(isinstance(val, int) for val in obj['ports'])
|
||||
case 2:
|
||||
valid = valid and isinstance(obj['topCount'], int)
|
||||
case 3:
|
||||
valid = valid and isinstance(obj['relatedString'], str)
|
||||
case _:
|
||||
valid = False
|
||||
|
||||
if valid:
|
||||
print(data)
|
||||
mm.vars['Scanner-Settings'] = data
|
||||
else:
|
||||
mm.sendPopupError(ac.rawClient, "Error", "There is an error in the config.")
|
||||
|
||||
|
||||
def startScanner(ac, data):
|
||||
@@ -26,11 +65,10 @@ def init(moduleMaster):
|
||||
mm = moduleMaster
|
||||
|
||||
mm.vars['Scanner-Settings'] = {
|
||||
"range": [[0,0,0,0], [255,255,255,255]],
|
||||
"numJobs": 30,
|
||||
"numJobs": 500,
|
||||
"maxPingTimeout": 3,
|
||||
"maxNmapTimeout": 2,
|
||||
"nmapGroupSize": 3,
|
||||
"nmapGroupSize": 10,
|
||||
|
||||
# Port modes:
|
||||
# -1: Disable
|
||||
@@ -40,21 +78,20 @@ def init(moduleMaster):
|
||||
|
||||
"tcpSettings": {
|
||||
"mode": 2,
|
||||
"ports": [631],
|
||||
"topCount": 10,
|
||||
"ports": [22, 80, 443],
|
||||
"topCount": 100,
|
||||
"relatedString": "http"
|
||||
},
|
||||
"udpSettings": {
|
||||
"mode": -1,
|
||||
"ports": [631, 161, 137, 123, 138],
|
||||
"topCount": 50,
|
||||
"ports": [631, 161, 137],
|
||||
"topCount": 100,
|
||||
"relatedString": "telnet"
|
||||
},
|
||||
"runTCP": True,
|
||||
"runUDP": False
|
||||
}
|
||||
}
|
||||
|
||||
mm.addPageEventListener('Scanner-LoadSettings', loadSettings)
|
||||
mm.addPageEventListener('/Scan/Scan', loadSettings)
|
||||
mm.addAuthEventListener('Scanner-SetSettings', setSettings)
|
||||
|
||||
mm.addAuthEventListener('Scanner-StartScanner', startScanner)
|
||||
mm.addAuthEventListener('Scanner-StopScanner', stopScanner)
|
||||
|
||||
+156
-4
@@ -1,16 +1,168 @@
|
||||
|
||||
<main class="container">
|
||||
<h4>This is a very simple example module!</h4>
|
||||
<h2>Scan Settings</h2>
|
||||
<button class="half-left" onclick="startScanner()">Start Scanner</button>
|
||||
<button class="half-right" onclick="stopScanner()">Stop Scanner</button>
|
||||
<button onclick="saveConfig()">Save Config</button>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>Number of scanning threads</p>
|
||||
<input id="settingsNumJobs" type="number" />
|
||||
<p>Ping command timeout (seconds)</p>
|
||||
<input id="settingsPingTimeout" type="number" />
|
||||
<p>Nmap command timeout (seconds)</p>
|
||||
<input id="settingsNmapTimeout" type="number" />
|
||||
<p>Nmap accumulated host count</p>
|
||||
<input id="settingsNmapGroupSize" type="number" />
|
||||
|
||||
<p>TCP Settings</p>
|
||||
<select id="settingsTCPDropdown" onchange="updateTCPDropdown()">
|
||||
<option selected value=-1>Disable</option>
|
||||
<option value=1>Specify ports</option>
|
||||
<option value=2>N Most common ports</option>
|
||||
<option value=3>Ports related to string</option>
|
||||
</select>
|
||||
<input id="settingsTCP" style="display: none;" />
|
||||
|
||||
<p>UDP Settings</p>
|
||||
<select id="settingsUDPDropdown" onchange="updateUDPDropdown()">
|
||||
<option selected value=-1>Disable</option>
|
||||
<option value=1>Specify ports</option>
|
||||
<option value=2>N Most common ports</option>
|
||||
<option value=3>Ports related to string</option>
|
||||
</select>
|
||||
<input id="settingsUDP" style="display: none;" />
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
window.main = ()=>{
|
||||
window.addListener('Scanner-LoadSettings', (data)=>{})
|
||||
function getel(el) {return document.getElementById(el)}
|
||||
|
||||
const settingsNumJobs = getel('settingsNumJobs')
|
||||
const settingsPingTimeout = getel('settingsPingTimeout')
|
||||
const settingsNmapTimeout = getel('settingsNmapTimeout')
|
||||
const settingsNmapGroupSize = getel('settingsNmapGroupSize')
|
||||
const settingsTCPDropdown = getel('settingsTCPDropdown')
|
||||
const settingsTCP = getel('settingsTCP')
|
||||
const settingsUDPDropdown = getel('settingsUDPDropdown')
|
||||
const settingsUDP = getel('settingsUDP')
|
||||
|
||||
let settings = {
|
||||
"numJobs": -1,
|
||||
"maxPingTimeout": -1,
|
||||
"maxNmapTimeout": -1,
|
||||
"nmapGroupSize": -1,
|
||||
|
||||
"tcpSettings": {
|
||||
"mode": -1,
|
||||
"ports": [],
|
||||
"topCount": -1,
|
||||
"relatedString": ""
|
||||
},
|
||||
"udpSettings": {
|
||||
"mode": -1,
|
||||
"ports": [],
|
||||
"topCount": -1,
|
||||
"relatedString": ""
|
||||
}
|
||||
}
|
||||
|
||||
function updateTCPDropdown(){
|
||||
if(settingsTCPDropdown.value == -1){
|
||||
settingsTCP.style.display = "none"
|
||||
}else{
|
||||
settingsTCP.style.display = ""
|
||||
switch(Number(settingsTCPDropdown.value)){
|
||||
case 1:
|
||||
settingsTCP.value = settings.tcpSettings.ports.join(", ")
|
||||
break;
|
||||
case 2:
|
||||
settingsTCP.value = settings.tcpSettings.topCount
|
||||
break;
|
||||
case 3:
|
||||
settingsTCP.value = settings.tcpSettings.relatedString
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getel(el) {return document.getElementById(el)}
|
||||
function updateUDPDropdown(){
|
||||
if(settingsUDPDropdown.value == -1){
|
||||
settingsUDP.style.display = "none"
|
||||
}else{
|
||||
settingsUDP.style.display = ""
|
||||
switch(Number(settingsUDPDropdown.value)){
|
||||
case 1:
|
||||
settingsUDP.value = settings.udpSettings.ports.join(", ")
|
||||
break;
|
||||
case 2:
|
||||
settingsUDP.value = settings.udpSettings.topCount
|
||||
break;
|
||||
case 3:
|
||||
settingsUDP.value = settings.udpSettings.relatedString
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.main = ()=>{
|
||||
|
||||
|
||||
|
||||
window.addListener('Scanner-Settings', (data)=>{
|
||||
settings = data.data
|
||||
settingsNumJobs.value = settings.numJobs
|
||||
settingsPingTimeout.value = settings.maxPingTimeout
|
||||
settingsNmapTimeout.value = settings.maxNmapTimeout
|
||||
settingsNmapGroupSize.value = settings.nmapGroupSize
|
||||
settingsTCPDropdown.value = settings.tcpSettings.mode
|
||||
settingsUDPDropdown.value = settings.udpSettings.mode
|
||||
|
||||
updateTCPDropdown()
|
||||
updateUDPDropdown()
|
||||
})
|
||||
|
||||
window.client.send('Scanner-LoadSettings', {})
|
||||
|
||||
}
|
||||
|
||||
function saveConfig() {
|
||||
settings.numJobs = Number(settingsNumJobs.value)
|
||||
settings.maxPingTimeout = Number(settingsPingTimeout.value)
|
||||
settings.maxNmapTimeout = Number(settingsNmapTimeout.value)
|
||||
settings.nmapGroupSize = Number(settingsNmapGroupSize.value)
|
||||
settings.tcpSettings.mode = Number(settingsTCPDropdown.value)
|
||||
settings.udpSettings.mode = Number(settingsUDPDropdown.value)
|
||||
|
||||
switch(Number(settingsTCPDropdown.value)){
|
||||
case 1:
|
||||
settings.tcpSettings.ports = settingsTCP.value.split(',').map(Number)
|
||||
break;
|
||||
case 2:
|
||||
settings.tcpSettings.topCount = Number(settingsTCP.value)
|
||||
break;
|
||||
case 3:
|
||||
settings.tcpSettings.relatedString = settingsTCP.value
|
||||
break;
|
||||
}
|
||||
|
||||
switch(Number(settingsUDPDropdown.value)){
|
||||
case 1:
|
||||
settings.udpSettings.ports = settingsUDP.value.split(',').map(Number)
|
||||
break;
|
||||
case 2:
|
||||
settings.udpSettings.topCount = Number(settingsUDP.value)
|
||||
break;
|
||||
case 3:
|
||||
settings.udpSettings.relatedString = settingsUDP.value
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log(settings)
|
||||
window.send("Scanner-SetSettings", settings)
|
||||
}
|
||||
|
||||
function startScanner() {
|
||||
window.send('Scanner-StartScanner', {})
|
||||
|
||||
Reference in New Issue
Block a user