egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

NMAP

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
mimizu
Voice


Joined: 20 Feb 2013
Posts: 7

PostPosted: Wed Feb 20, 2013 4:30 am    Post subject: NMAP Reply with quote

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
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Wed Feb 20, 2013 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
dirty
Halfop


Joined: 08 Feb 2013
Posts: 40
Location: Romania

PostPosted: Wed Feb 20, 2013 8:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Feb 20, 2013 9:42 am    Post subject: Reply with quote

Public access to exec.. bad idea in the first place. Shocked

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
View user's profile Send private message
dirty
Halfop


Joined: 08 Feb 2013
Posts: 40
Location: Romania

PostPosted: Wed Feb 20, 2013 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Feb 20, 2013 2:52 pm    Post subject: Reply with quote

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... Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
dirty
Halfop


Joined: 08 Feb 2013
Posts: 40
Location: Romania

PostPosted: Wed Feb 20, 2013 3:14 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mimizu
Voice


Joined: 20 Feb 2013
Posts: 7

PostPosted: Thu Feb 21, 2013 12:06 am    Post subject: Reply with quote

I am trying to master ...

Wishing success ^ ^


Thank you very much before and after ....
Back to top
View user's profile Send private message
mimizu
Voice


Joined: 20 Feb 2013
Posts: 7

PostPosted: Thu Feb 21, 2013 1:49 am    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Feb 21, 2013 2:09 am    Post subject: Reply with quote

It's caesar damn it, also notice the lowercase Cool Razz

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
View user's profile Send private message
mimizu
Voice


Joined: 20 Feb 2013
Posts: 7

PostPosted: Thu Feb 21, 2013 2:45 am    Post subject: Reply with quote

check port 1 by 1 x_x

nmap check all open and close port.... ^^

CMIWW
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Feb 21, 2013 10:41 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber