diff --git a/.gitignore b/.gitignore index 7aabe9d..9e86591 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ scans/* +logs/* scratch* *.bak* *.old* diff --git a/index.php b/index.php index c7f5cda..cbb5258 100644 --- a/index.php +++ b/index.php @@ -15,6 +15,9 @@
- + +
+ \ No newline at end of file diff --git a/js/nmaprincesspi.js b/js/nmaprincesspi.js index b2faade..92fd010 100644 --- a/js/nmaprincesspi.js +++ b/js/nmaprincesspi.js @@ -14,8 +14,8 @@ function copyToClipboard(ID) { function xhrSuccess(xhrRet) { let xhrResponseText = xhrRet.target.responseText; - getID('out').innerHTML = 'Scan Report Here ('+xhrResponseText+')'; - getID('out').style.display = "inline"; + getID('link').innerHTML = 'Scan Report Here ('+xhrResponseText+')'; + getID('link').style.display = "inline"; } function xhr404(xhrRet) { @@ -41,9 +41,9 @@ function xhrLoadend(xhrRet) { } } -function doXhr(xhrFilePath, xhrMethod='GET', xhrPostData=null) { +function doXhr(xhrFilePath, xhrLoadEndFun=xhrLoadEnd, xhrMethod='GET', xhrPostData=null) { const xhr = new XMLHttpRequest(); - xhr.addEventListener("loadend", xhrLoadend); + xhr.addEventListener("loadend", xhrLoadEndFun); xhr.open(xhrMethod, xhrFilePath); if(xhrMethod == 'POST') { @@ -68,15 +68,39 @@ function changeFavIcon(icoFile) { icoLink.href = icoFile; } -function runNmapScan() { - let nmapcmd = getID('nmapcmd').value; - console.log(nmapcmd); - let postData = 'nmapcmd='+encodeURIComponent(nmapcmd); - doXhr('run_scan.php', 'POST', postData); +function xhrRunNmapScan(xhrRet) { + // let xhrResponseText = xhrRet.target.responseText; + xhrJson = JSON.parse(xhrRet.target.responseText); + + getID('link').innerHTML = 'Scan Report Here ('+xhrJson.webName+')'; + getID('link').style.display = "inline"; + + if(typeof pollInterval !== 'undefined') { + clearInterval(pollInterval); + } + + getID('progress').innerHTML = ''; + getID('progress').style.display = 'none'; + + pollFile(xhrJson.runningLog); + } -function pollFile(filePath) { - var poll = setInterval(function() { - doXhr(filePath); +function xhrPollFile(xhrRet) { + let xhrResponseText = xhrRet.target.responseText; + getID('progress').innerHTML = xhrResponseText; + getID('progress').style.display = "block"; +} + +function pollFile(runningLog) { + var pollInterval = setInterval(function() { + doXhr(runningLog, xhrPollFile); }, 1000); +} + +function runNmapScan() { + let nmapcmd = getID('nmapcmd').value; + let postData = 'nmapcmd='+encodeURIComponent(nmapcmd); + + doXhr('run_scan.php', xhrRunNmapScan, 'POST', postData); } \ No newline at end of file diff --git a/run_scan.php b/run_scan.php index 5a93f74..4dfa728 100644 --- a/run_scan.php +++ b/run_scan.php @@ -11,8 +11,6 @@ $run_cmd = "bash ./scripts/run_scan.sh nmap -oX ./scans/$file_name --stylesheet /nmaprincesspi/xsl/princesspi-nmap.xsl $post_cmd"; $web_name = "/nmaprincesspi/scans/$file_name"; - echo $web_name; - - $exec = shell_exec($run_cmd); - echo $exec; + $exec = trim(shell_exec($run_cmd)); + echo "{\"runningLog\":\"$exec\",\"webName\":\"$web_name\"}"; ?> \ No newline at end of file diff --git a/running.log b/running.log deleted file mode 100644 index 29a0a13..0000000 --- a/running.log +++ /dev/null @@ -1,12 +0,0 @@ -Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-15 16:07 MDT -Nmap scan report for kasm.h.acker.is (64.20.45.110) -Host is up (0.070s latency). -Not shown: 995 filtered tcp ports (no-response) -PORT STATE SERVICE -22/tcp open ssh -80/tcp open http -443/tcp open https -3389/tcp open ms-wbt-server -8888/tcp open sun-answerbook - -Nmap done: 1 IP address (1 host up) scanned in 7.70 seconds diff --git a/scripts/fix_perms.sh b/scripts/fix_perms.sh index a128a1b..21fadad 100755 --- a/scripts/fix_perms.sh +++ b/scripts/fix_perms.sh @@ -1,2 +1,3 @@ #!/bin/bash -sudo chown -R www-data:www-data .. 2>>../error.log \ No newline at end of file +sudo chown -R www-data:www-data .. 2>>../logs/error.log +sudo chmod +x ../logs/* \ No newline at end of file diff --git a/nmap-script.sh b/scripts/nmap-script.sh similarity index 100% rename from nmap-script.sh rename to scripts/nmap-script.sh diff --git a/scripts/run_clear.sh b/scripts/run_clear.sh index 7a71bb1..2011c51 100755 --- a/scripts/run_clear.sh +++ b/scripts/run_clear.sh @@ -1,4 +1,3 @@ #!/bin/bash -rm -f ../error.log 2>>./error.log -rm -f ../running.log 2>>./error.log -rm -f ../scans/* 2>>./error.log \ No newline at end of file +rm -f ../log/* 2>>../logs/error.log +rm -f ../scans/* 2>>../logs/error.log \ No newline at end of file diff --git a/scripts/run_scan.sh b/scripts/run_scan.sh index 0155396..60d9c26 100755 --- a/scripts/run_scan.sh +++ b/scripts/run_scan.sh @@ -1,2 +1,4 @@ #!/bin/bash -eval "$* 2>error.log 1>running.log&" \ No newline at end of file +runningLog="$(date +%Y%m%d%H%M%S)-$RANDOM.log" +eval "$* 2>>logs/error.log 1>logs/$runningLog&" +echo "/nmaprincesspi/logs/$runningLog" \ No newline at end of file diff --git a/todo.txt b/todo.txt index 0977d0d..202a40b 100644 --- a/todo.txt +++ b/todo.txt @@ -12,4 +12,10 @@ scans listing c work on scans filename? fix perms auth system -input/output validation \ No newline at end of file +input/output validation +work on princesspi-nmap.xsl + clean up + minimize stuff + remove rundundant code + make prettier + green class \ No newline at end of file