[or-cvs] r11046: saturday evening hacking :) (in topf/trunk: . lib)

benedikt at seul.org benedikt at seul.org
Sat Aug 4 21:44:49 UTC 2007


Author: benedikt
Date: 2007-08-04 17:44:49 -0400 (Sat, 04 Aug 2007)
New Revision: 11046

Modified:
   topf/trunk/lib/control.rb
   topf/trunk/lib/fuzz.rb
   topf/trunk/tor-control-fuzz.rb
Log:
saturday evening hacking :)

Modified: topf/trunk/lib/control.rb
===================================================================
--- topf/trunk/lib/control.rb	2007-08-04 16:27:01 UTC (rev 11045)
+++ topf/trunk/lib/control.rb	2007-08-04 21:44:49 UTC (rev 11046)
@@ -2,15 +2,17 @@
     module Control
         class ItemFuzz
             attr_reader :item
-            def initialize(item, fields, values)
+            def initialize(item, tests, fields, values)
                 raise "item is not a BitStruct" if !item.is_a?(BitStruct)
                 @item = item
+                @tests = tests
                 @fields = fields
                 @values = values
                 @count = 0
             end
 
             def set_next
+                raise "all pairs set" if @count == @values.size
                 @fields.each_with_index do |field, index|
                     method = field.to_s + "="
                     value = @values[@count][index]
@@ -21,13 +23,18 @@
             end
             
             def prepare!
-                @item.prepare!
+                @item.prepare! @tests
             end
 
             def fuzz!
-                @item.fuzz!
+                begin
+                    @item.fuzz!
+                rescue
+                    self.set_next
+                    self.prepare!
+                    @item.fuzz!
+                end
             end
-
         end
 
         SETCONF_KEYS = [
@@ -46,14 +53,13 @@
             [ "address-mappings/all", "" ],
             [ "address-mappings/config", "" ],
             [ "address-mappings/cache", "" ],
-            [ "address-mappings/control", "" ]
-            [ "addr-mappings/*", "" ]
-            [ "address", "127.0.0.1" ] 
-            [ "fingerprint", "contents of fingerprint file" ]
+            [ "address-mappings/control", "" ],
+            [ "addr-mappings/*", "" ],
+            [ "address", "127.0.0.1" ], 
+            [ "fingerprint", "contents of fingerprint file" ],
             [ "circuit-status", "" ]
 =begin
-                                                  A series of lines as for a circuit status event. Each line is of
-                                                  the form:
+A series of lines as for a circuit status event. Each line is of the form:
                                                      CircuitID SP CircStatus [SP Path] CRLF
 
                                                 "stream-status"
@@ -89,8 +95,8 @@
         ]
 
         class SetConfItem < BitStruct
-            text :item, 7, :fuzzable => true 
-            text :keyword, 30, :fuzzable => false
+            text :item, 7
+            text :keyword, 30
             text :assign, 1
             rest :value
 

Modified: topf/trunk/lib/fuzz.rb
===================================================================
--- topf/trunk/lib/fuzz.rb	2007-08-04 16:27:01 UTC (rev 11045)
+++ topf/trunk/lib/fuzz.rb	2007-08-04 21:44:49 UTC (rev 11046)
@@ -255,8 +255,9 @@
                     self.send data
                     assert(args[:assert] )
                 end
-            rescue Exception
-                puts "[!] ERROR: %s" % $!
+            rescue Exception => exception
+                Fuzz::LOGGER.debug "[!] ERROR: %s" % $!
+                Fuzz::LOGGER.debug "[!] \n%s" % exception.backtrace.join("\n")
             end
         end
 

Modified: topf/trunk/tor-control-fuzz.rb
===================================================================
--- topf/trunk/tor-control-fuzz.rb	2007-08-04 16:27:01 UTC (rev 11045)
+++ topf/trunk/tor-control-fuzz.rb	2007-08-04 21:44:49 UTC (rev 11046)
@@ -3,11 +3,17 @@
 begin
     Fuzz::LOGGER.debug "[x] starting tor"
     observer = Fuzz::BinaryObserver.new "tor", "-f torrc", "&> /dev/null"
+
     observer.observe!
-    
+    sleep 2 
     Fuzz::LOGGER.debug "[x] tor pid: %d" % observer.get_pid
-    sleep 1 
-    
+#    if !observer.get_pid
+#        started = false
+#        raise "Fork error"
+#    else
+#        started = true
+#    end
+   
     Fuzz::LOGGER.debug "[x] loading options"
 
     config = YAML::load_file "config.yml"
@@ -16,7 +22,7 @@
         :host => config["HOST"], 
         :port => config["CONTROLPORT"],
         :type => :tcp,
-        :debug => true
+        :debug => false
     }
 
     Fuzz::LOGGER.debug "[x] connecting to control port"
@@ -28,16 +34,28 @@
     fuzzer.send auth 
     fuzzer.assert ["250 OK"]
     
-    setconf = TOPF::Control::SetConfItem.new
+    setconffuzz = TOPF::Control::ItemFuzz.new( TOPF::Control::SetConfItem.new, 
+                                            Fuzz::DEFAULT_TESTS, 
+                                            [:keyword, :value], 
+                                            TOPF::Control::SETCONF_KEYS )
 
-    setconf.keyword = "blah" 
-    setconf.value   = "test"
-    setconf.prepare! Fuzz::DEBUG_TESTS
-    
-    Fuzz::LOGGER.debug "[x] start fuzzing #{setconf.class}"
 
-    fuzzer.fuzz! setconf, " ", { :append => "\r\n",
-                                 :assert => TOPF::Control::SETCONF_REPLYS }
+    resetconffuzz = TOPF::Control::ItemFuzz.new( TOPF::Control::ResetConfItem.new,
+                                            Fuzz::DEFAULT_TESTS,
+                                            [:keyword, :value],
+                                            TOPF::Control::SETCONF_KEYS )
+
+    getconffuzz   = TOPF::Control::ItemFuzz.new( TOPF::Control::GetConfItem.new,
+                                            Fuzz::DEFAULT_TESTS,
+                                            [:keyword, :value],
+                                            TOPF::Control::SETCONF_KEYS )
+
+
+    Fuzz::LOGGER.debug "[x] start fuzzing #{setconffuzz.class}"
+
+    fuzzer.fuzz!( setconffuzz, " ", { :append => "\r\n",
+                                   :assert => TOPF::Control::SETCONF_REPLYS } )
+
     fuzzer.close 
 
     observer.exit
@@ -46,5 +64,5 @@
     Fuzz::LOGGER.debug "[!] \n%s" % blah.backtrace.join("\n")
     Fuzz::LOGGER.debug "[!] closing everything down"
     fuzzer.close if fuzzer
-    observer.exit if observer
+    observer.exit if observer and started
 end



More information about the tor-commits mailing list