bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan args} {
putserv "PRIVMSG $chan : Scanning...... $args wait................!!"
global data_var
set data_var [exec nmap $args]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
putlog "<<$chan>> !$handle! !nmap"
}
please help, to fix nmap script above.
if anyone did order !nmap nmap it will wait for the process is complete and can not process !nmap with a message on the channel "please wait a moment, are doing nmap"
Public access to exec.. bad idea in the first place.
Not to mention the info exists progress will work for the first time, then will not allow the script to continue.
I think you meant to create an global variable outside the port_scan proc (after bind line, like set progress 0) then match it's value against 1 or 0 like if {$progress} or if {!$progress} and proceed with return or continue. Oh, and guys please refrain from using $args as has special meaning in TCL.
Once the game is over, the king and the pawn go back in the same box.
!nmap [return "[adduser nick] [chattr nick +fgmnov]"]
Here we show that using [exec] over unsanitized user input will let "nick" takeover your bot. Using the !nmap line above and replace "nick" with your nickname. You should see "1 fgmnov" when you gain ownership of the bot via this method, not the normal nmap reply expected.
Also:
Caeser wrote:Not to mention the info exists progress will work for the first time, then will not allow the script to continue.
Yeah, not to mention that the script will run once and then not work again because of that variable "progress". You think tcl is threaded? It isn't...
Yes your right speachles and caesar.. but i only fixed the "info exists" and $args to $text part.. the part with exec can be fixed by checking $text for specific pattern or by limiting the command with a "bind pub n| !nmap port_scan"
Someone with bad intentions could compromise the box this is running, not just the bot. If you wish to check if a port is open or not, why not use one of user's scripts like socket api - nonblocking tcp made easy?
Or, if you wish to insist on using nmap, if there are certain arguments an user would use anyway why not add this modes inside the function and request user only for a valid IP adress? There are a few examples on Regular Expression Examples with a regexp or scan to do this IP validation.
Once the game is over, the king and the pawn go back in the same box.
There's no need to quote the previous post if you intend to reply to that, and second, nmap dose exactly the same thing, except it already has a predefined list of ports to check so you just have to feed it with an IP address.
Once the game is over, the king and the pawn go back in the same box.