| View previous topic :: View next topic |
| Author |
Message |
mimizu Voice
Joined: 20 Feb 2013 Posts: 7
|
Posted: Wed Feb 20, 2013 4:30 am Post subject: NMAP |
|
|
| Quote: | 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"
Please help.
thank you |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Wed Feb 20, 2013 7:09 am Post subject: |
|
|
Try this
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan args} {
global progress
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $args wait................!!"
set progress 1
set data_var [exec nmap $args]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
set progress 0
putlog "<<$chan>> !$handle! !nmap"
}
|
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
dirty Halfop
Joined: 08 Feb 2013 Posts: 40 Location: Romania
|
Posted: Wed Feb 20, 2013 8:27 am Post subject: |
|
|
And maybe add some protection so that it won`t scan if someone uses !nmap without any $args
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan args} {
global progress
if {$args == ""} { putserv "PRIVMSG $chan :Error. No arguments specified."; return }
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $args wait................!!"
putlog "<<$chan>> !$handle! !nmap"
set progress 1
set data_var [exec nmap $args]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
set progress 0
}
|
_________________ come to the dark side.. I have cookies!
WwW.BotZone.TK |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Feb 20, 2013 9:42 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
dirty Halfop
Joined: 08 Feb 2013 Posts: 40 Location: Romania
|
Posted: Wed Feb 20, 2013 9:58 am Post subject: |
|
|
Not really caesar.. could be done this way..
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan text} {
global progress
if {$text == ""} { putserv "PRIVMSG $chan :Error. No arguments specified."; return }
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $text wait................!!"
putlog "<<$chan>> !$handle! !nmap"
set progress 1
set data_var [exec nmap $text]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
unset -nocomplain progress
}
|
_________________ come to the dark side.. I have cookies!
WwW.BotZone.TK |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Feb 20, 2013 2:52 pm Post subject: |
|
|
Caeser is right. An attacker can compromise your bot pretty immediately otherwise. For example, the code below:
| Code: | | !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...  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
dirty Halfop
Joined: 08 Feb 2013 Posts: 40 Location: Romania
|
Posted: Wed Feb 20, 2013 3:14 pm Post subject: |
|
|
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" _________________ come to the dark side.. I have cookies!
WwW.BotZone.TK |
|
| Back to top |
|
 |
mimizu Voice
Joined: 20 Feb 2013 Posts: 7
|
Posted: Thu Feb 21, 2013 12:06 am Post subject: |
|
|
I am trying to master ...
Wishing success ^ ^
Thank you very much before and after .... |
|
| Back to top |
|
 |
mimizu Voice
Joined: 20 Feb 2013 Posts: 7
|
Posted: Thu Feb 21, 2013 1:49 am Post subject: |
|
|
Sir...
If i use :
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan args} {
global progress
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $args wait................!!"
set progress 1
set data_var [exec nmap $args]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
set progress 0
putlog "<<$chan>> !$handle! !nmap"
}
|
or
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan args} {
global progress
if {$args == ""} { putserv "PRIVMSG $chan :Error. No arguments specified."; return }
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $args wait................!!"
putlog "<<$chan>> !$handle! !nmap"
set progress 1
set data_var [exec nmap $args]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
set progress 0
}
|
if command !nmap reused, the message:
| Quote: | | nmap in progress please wait to finish.. |
when I use:
| Code: |
bind pub - !nmap port_scan
proc port_scan {nick uhost handle chan text} {
global progress
if {$text == ""} { putserv "PRIVMSG $chan :Error. No arguments specified."; return }
if {[info exists progress]} { putserv "PRIVMSG $chan :nmap in progress please wait to finish.."; return }
putserv "PRIVMSG $chan : Scanning...... $text wait................!!"
putlog "<<$chan>> !$handle! !nmap"
set progress 1
set data_var [exec nmap $text]
set l [split $data_var "\r\n"]
foreach i $l { puthelp "PRIVMSG $chan : $i " }
unset -nocomplain progress
}
|
The script can not invoke nmap in linux server.
Thanks |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Feb 21, 2013 2:09 am Post subject: |
|
|
It's caesar damn it, also notice the lowercase
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. |
|
| Back to top |
|
 |
mimizu Voice
Joined: 20 Feb 2013 Posts: 7
|
Posted: Thu Feb 21, 2013 2:45 am Post subject: |
|
|
check port 1 by 1 x_x
nmap check all open and close port.... ^^
CMIWW |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Feb 21, 2013 10:41 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|