<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/16827" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2009-04-28T11:43:45-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/16827</id>

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-28T11:43:45-04:00</updated>

		<published>2009-04-28T11:43:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88605#p88605</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88605#p88605"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88605#p88605"><![CDATA[
Well, first off, your regular expression is flawed. It will check if there is atleast one digit in strength, but won't care if there's any non-digit in it.<br>My example is slightly flawed, as it did not contain a digit, but do try "!attack foo 0[die]".<br><br>In this case, our regexp checks the value of strength (0[die]) against the pattern [0-9]. Since there is atleast one digit in there, there will be a match, and accepted.<br>Next, we preprocess this line:<div class="codebox"><p>Code: </p><pre><code>set newstrength [expr $strength * 2]#Command substitution:expr $strength * 2#Variable substitutionexpr {0[die]} * 2</code></pre></div>Unfortunately, expr will do it's own set of command and variable substitutions:<div class="codebox"><p>Code: </p><pre><code>expr {0[die]} * 2 =&gt; "0[die] * 2"#command substitutiondie#Oops, our bot died</code></pre></div>There is no option to tell expr not to do variable substitutions, but just as with eval, you can use proper list structures (if you are careful) to prevent remote code injection. Hence, it is very very important to make sure whatever you pass to expr is safe.<br>If you'll check one of my earlier posts, you'll find a replacement regexp with proper regular expression. It makes use of the special tokens ^ (start of line) and $ (end of line), and inbetween these, one or more digits. <br><br><br>Next, not a major security issue, but it's bad coding, and will break on more complex input. Don't use lindex, lrange, etc on strings. They're supposed to be used on list, and nothing else. If you need to convert a string into a list, there's the split command.<div class="codebox"><p>Code: </p><pre><code>proc attack {nick uhost handle chan text} { set arg [split $text] set user [lindex $arg 0] set strength [lindex $arg 1]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 28, 2009 11:43 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2009-04-28T00:40:45-04:00</updated>

		<published>2009-04-28T00:40:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88602#p88602</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88602#p88602"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88602#p88602"><![CDATA[
nml375: was refering to timy but go on and speak more about possible "leaks" or exploits and how to prevent them as i am interested in it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Tue Apr 28, 2009 12:40 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-27T12:31:00-04:00</updated>

		<published>2009-04-27T12:31:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88599#p88599</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88599#p88599"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88599#p88599"><![CDATA[
raider2k: Me or Timy?<br><br>Regarding my post, try "!attack foo [die]", and you'll see what I'm saying...<br><br>Regarding Timy's post, this sounds like a side-effect of the issue in my post. Most likely, some kind of garbage makes it through, causing expr to bark...<br><br>In any case, whenever you are passing data from an untrusted source to expr, extreme care must be taken to validate the data. Sloppy coding could very well result in a remote execution exploit.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Apr 27, 2009 12:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2009-04-27T00:11:21-04:00</updated>

		<published>2009-04-27T00:11:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88591#p88591</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88591#p88591"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88591#p88591"><![CDATA[
please re-try describing what the problem is because i was not able to understand it. and maybe put some examples<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Mon Apr 27, 2009 12:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Timy]]></name></author>
		<updated>2009-04-25T11:28:33-04:00</updated>

		<published>2009-04-25T11:28:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88570#p88570</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88570#p88570"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88570#p88570"><![CDATA[
<blockquote class="uncited"><div>since i dont know what defense and spy exactly are going to do, heres the half-done code containing fully working attack code.<br><br>if i got something wrong please tell me about it and i will try to fix it asap <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><div class="codebox"><p>Code: </p><pre><code>bind pub - !attack attackbind pub - !defense defendbind pub - !spy spyproc attack { nick uhost handle chan text } {set user [lindex $text 0]set strength [lindex $text 1]### MAKES SURE THAT BOTH USERNAME AND STRENGTH GET FILLEDif { [string equal $strength ""] } {putserv "PRIVMSG $chan :syntax: !attack \$username \$strength-to-attack-with"return 0}if { ![regexp -all -nocase -- {[0-9]} $strength] } {### MAKES SURE THAT STRENGTH IS NUMERIC CHARS ONLYputserv "PRIVMSG $chan :please supply numerical characters only"return 0}### CALCULATION OF STRENGTH * 2 BELOWset newstrength [expr $strength * 2]### OUTPUT TO CHANNEL WHAT HAS HAPPENED BELOWputserv "PRIVMSG $chan :$nick attacks $user with $newstrength hitpoints"}proc defend { nick uhost handle chan text } {#### CODE HERE}proc spy { nick uhost handle chan text } {#### CODE HERE}</code></pre></div>not tested, but should work though <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"></div></blockquote>that wok with me vry fine, but i have on poblem.<br><br>but when i change number to multiply with from 2 to 3500, it work with ight out put whn i ntr number less than 6 digits, but when i nter number more than 6 digits it will give me wrong out put, but when i make it as 3000 instead of 3500 its wok normal evn if input moe than 6 digits, so what i need to change to let it work ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8297">Timy</a> — Sat Apr 25, 2009 11:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-21T15:45:21-04:00</updated>

		<published>2009-04-21T15:45:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88527#p88527</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88527#p88527"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88527#p88527"><![CDATA[
Please don't use lindex on strings. Atleast use split to convert it into a list first.<br><br>Also, your regular expression is flawed, as it will let non-digit characters pass through..<br>A proper regular expression would look like this:<div class="codebox"><p>Code: </p><pre><code>set strength [lindex [split $text] 1]if {![regexp -- {^[[:digit:]]+$} $strength} {...</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Apr 21, 2009 3:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2009-04-21T13:23:36-04:00</updated>

		<published>2009-04-21T13:23:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88526#p88526</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88526#p88526"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88526#p88526"><![CDATA[
since i dont know what defense and spy exactly are going to do, heres the half-done code containing fully working attack code.<br><br>if i got something wrong please tell me about it and i will try to fix it asap <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><div class="codebox"><p>Code: </p><pre><code>bind pub - !attack attackbind pub - !defense defendbind pub - !spy spyproc attack { nick uhost handle chan text } {set user [lindex $text 0]set strength [lindex $text 1]### MAKES SURE THAT BOTH USERNAME AND STRENGTH GET FILLEDif { [string equal $strength ""] } {putserv "PRIVMSG $chan :syntax: !attack \$username \$strength-to-attack-with"return 0}if { ![regexp -all -nocase -- {[0-9]} $strength] } {### MAKES SURE THAT STRENGTH IS NUMERIC CHARS ONLYputserv "PRIVMSG $chan :please supply numerical characters only"return 0}### CALCULATION OF STRENGTH * 2 BELOWset newstrength [expr $strength * 2]### OUTPUT TO CHANNEL WHAT HAS HAPPENED BELOWputserv "PRIVMSG $chan :$nick attacks $user with $newstrength hitpoints"}proc defend { nick uhost handle chan text } {#### CODE HERE}proc spy { nick uhost handle chan text } {#### CODE HERE}</code></pre></div>not tested, but should work though <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Tue Apr 21, 2009 1:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Timy]]></name></author>
		<updated>2009-04-21T09:19:53-04:00</updated>

		<published>2009-04-21T09:19:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88524#p88524</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88524#p88524"/>
		<title type="html"><![CDATA[Calculation Tcl]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88524#p88524"><![CDATA[
Dear All;<br><br>   Need support to have Tcl as follow :<br><br>to define those strength as follow<br><br>Attack = input number * 2<br>Defense = input number * 3<br>Spy = input number * 4<br><br>so when user make on main input as : Attack 200<br>so i need out to be as follow : username 400<br><br>so automatice it will multiply the input number which is related for Attack mean it need to multiply by 2 and give the answer to user.<br><br>so please need such tsl, for who can help me about it<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8297">Timy</a> — Tue Apr 21, 2009 9:19 am</p><hr />
]]></content>
	</entry>
	</feed>
