Forráskód Böngészése

unique users counting should work now.found the b!

Paul Klumpp 12 éve
szülő
commit
549d91eb90
2 módosított fájl, 58 hozzáadás és 17 törlés
  1. 11 5
      cims.tcl
  2. 47 12
      putils.tcl

+ 11 - 5
cims.tcl

@@ -598,11 +598,12 @@ proc ::cims::put_bot {botnetnick data} {
 	if {$testlink == 1} {
 		putlog "::cims:: put_bot: + a message delivered to $botnetnick."
 		
-		#if {[string length $data] > 335} {
-		#	::putils::put_bot $botnetnick $data
-		#} else {
+		if {[string length $data] > 335} {
+			::putils::filelog "scripts/cims/cims.log" "alldata put_bot to $botnetnick: $data"
+			::putils::put_bot $botnetnick $data
+		} else {
 			putbot $botnetnick $data
-		#}
+		}
 	} else {
 		putlog "::cims:: put_bot: + a message couldn't be delivered. Bot $botnetnick is not linked"
 	}
@@ -754,8 +755,13 @@ proc ::cims::receive_message {rec_botnick cmd rec_data} {
 		}
 	}
 
+	# building a fake userlist of 500 people for debugging:
+#	for {set x 0} {$x < 500} {incr x} {
+#		set unique_userlist [lsort -unique [concat $unique_userlist [::putils::randomRangeString 6]]]
+#	}
 
-	
+
+	putlog "unique_userlist is [llength $unique_userlist] long"
 	
 	# it is an eggdrop limitation/bug that it is not allowed to send large botnet messages via putbot. 
   # it truncates our payload after 388 chars. in fact the payload is 401 chars.

+ 47 - 12
putils.tcl

@@ -70,7 +70,7 @@ proc ::putils::kill_spaces {text} {
 
 proc ::putils::put_bot {target_botnetnick fromdata} {
 	# real maxlen for putbot is 400. but we have overhead.
-	set maxmsglen 330
+	set maxmsglen 300
 	
 	set calcmsglen [expr $maxmsglen + 1]
 
@@ -81,9 +81,10 @@ proc ::putils::put_bot {target_botnetnick fromdata} {
 
 		# prepare data ...! encode. send multiple data, if needed.
 		# encode it, base64
-		set data [::base64::encode $fromdata]
+		set data [::base64::encode -wrapchar "" $fromdata]
 		putlog "base64: $data"
-		
+		::putils::filelog "scripts/cims/cims.log" "put_bot to $target_botnetnick: full base64 $data"
+
 		# make a hash of $data
 		set md5 [::md5::md5 -hex $data]
 		putlog "md5: $md5"
@@ -111,14 +112,15 @@ proc ::putils::put_bot {target_botnetnick fromdata} {
 #OTA=
 		# cut data into pieces and send!
 		for {set x 0} {$x < $count_parts} {incr x} {
-			puts "x is $x"
+			putlog "part number is $x"
 
 			# get the part
 			set part [string range $data 0 $maxmsglen]
+			putlog "part is $part"
 
 			# kill the part out of the original string
 			set data [string replace $data 0 $maxmsglen ""]
-			
+			::putils::filelog "scripts/cims/cims.log" "put_bot to $target_botnetnick: $part"
 			putbot $target_botnetnick [concat "rec_putils " $md5 " " [expr $x + 1] " " $count_parts " " $part]
 		}
 		
@@ -132,6 +134,23 @@ proc ::putils::put_bot {target_botnetnick fromdata} {
 
 }
 
+#
+# Proc to generate a string of (given) characters
+# Range defaults to "ABCDEF...wxyz'
+#
+proc ::putils::randomRangeString {length {chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}} {
+  set range [expr {[string length $chars]-1}]
+
+  set txt ""
+  for {set i 0} {$i < $length} {incr i} {
+     set pos [expr {int(rand()*$range)}]
+     append txt [string range $chars $pos $pos]
+  }
+  return $txt
+}
+
+
+
 proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 	# cmd is "rec_putils"
 	#putlog "inside rec_bot. we want to decode rec_data: $rec_data"
@@ -169,6 +188,8 @@ proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 	set kill_timer_id [utimer 2 "::putils::timer_cleanup"]
 
 	proc ::putils::timer_cleanup {} {
+		variable themessage
+		variable kill_coordinates
 		set themessage ""
 		set kill_coordinates ""
 	}
@@ -197,6 +218,8 @@ proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 				
 				# insert the element into the right place of the X-count-element list
 				lset base64 [expr $current_part - 1] $base64data
+				#putlog "building base64: $base64"
+
 				# save the coordinates for later deletion.
 				#1*4 - 4 3 2 1
 				set kill_from [expr ($iteration * 4) - 4]
@@ -206,11 +229,12 @@ proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 				
 				if {$my_count == $count} {
 					regsub -all " " ${base64} "" base64
-					#putlog "base64: $base64"
+					#putlog "finished base64: $base64"
+					
 					set finish 1
 					# now delete this 4 from the $themessage
 					foreach {kill_from kill_to} $kill_coordinates {
-						putlog "kill_from: $kill_from kill_to: $kill_to"
+						#putlog "kill_from: $kill_from kill_to: $kill_to"
 						for {set y $kill_from} {$y <= $kill_to} {incr y} {
 							lset themessage $y "X"
 							#putlog "themessage: $themessage"
@@ -224,16 +248,14 @@ proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 	}
 
 	if {$finish == 1} {
-		putlog "base64: $base64"
+		#::putils::filelog "scripts/cims/cims.log" "rec_bot from $sender_botnetnick base64: $base64"
 		# decode base64data ... 
 		set original_data [::base64::decode $base64]
-		#putlog "original_data1: $original_data"
-		#set original_data [split $original_data]
-		putlog "original_data2: $original_data"
+		#putlog "original_data: $original_data"
 
 		set md5 [::md5::md5 -hex $base64]
 		if {$md5 == $message_hash} {
-			putlog "alright md5"
+			putlog "received decoded base64 message with correct md5"
 			# start the targetted procedure with the received data. if available.
 			set bindlist [split [join [binds bot]]]
 			foreach {type o cmd cnt procedure} $bindlist {
@@ -334,6 +356,19 @@ proc ::putils::read_f_array {file} {
   return [array get myinternalarray]
 }
 
+proc ::putils::filelog {file txt} {
+	
+	# write all to it
+	set timestamp [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]
+	
+	#open handle
+	set fh [open "$file" "a"]
+	# put to handle
+	puts $fh "$timestamp $txt"
+	# close handle
+	close $fh
+}
+
 
 
 return 1