summarylogtreecommitdiffstats
path: root/fix-syntax-warnings.patch
blob: d62ac412a6a496bf2f933b9090a02aa86e49f474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
--- a/ropper/arch.py
+++ b/ropper/arch.py
@@ -244,9 +244,9 @@ class ArchitectureX86(Architecture):
 
     def _initCategories(self):
         self._categories = {
-                gadget.Category.STACK_PIVOT : (('^sub (?P<dst>.sp), (?P<src>[x0-9a-fA-F]+)$','^add (?P<dst>.sp), (?P<src>[x0-9a-fA-F]+)$','^mov (?P<dst>.sp), .+ ptr \[(?P<src>...)\]$','^mov (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>...), (?P<src>.sp)$','ret.+'),('push','mov','call','jmp')),
-                gadget.Category.LOAD_MEM : (('mov (?P<dst>...), .+ ptr \[(?P<src>...)\]',),('push','mov','call','jmp')),
-                gadget.Category.WRITE_MEM : (('^mov .+ ptr \[(?P<dst>...)\], (?P<src>...)$',),('push','mov','call','jmp')),
+                gadget.Category.STACK_PIVOT : ((r'^sub (?P<dst>.sp), (?P<src>[x0-9a-fA-F]+)$',r'^add (?P<dst>.sp), (?P<src>[x0-9a-fA-F]+)$',r'^mov (?P<dst>.sp), .+ ptr \[(?P<src>...)\]$',r'^mov (?P<dst>.sp), (?P<src>...)$',r'^xchg (?P<dst>.sp), (?P<src>...)$',r'^xchg (?P<dst>...), (?P<src>.sp)$','ret.+'),('push','mov','call','jmp')),
+                gadget.Category.LOAD_MEM : ((r'mov (?P<dst>...), .+ ptr \[(?P<src>...)\]',),('push','mov','call','jmp')),
+                gadget.Category.WRITE_MEM : ((r'^mov .+ ptr \[(?P<dst>...)\], (?P<src>...)$',),('push','mov','call','jmp')),
                 gadget.Category.LOAD_REG : (('pop (?P<dst>...)',),('push','mov','call','jmp')),
                 gadget.Category.JMP : (('^jmp (?P<dst>...)$',),()),
                 gadget.Category.CALL : (('^call (?P<dst>...)$',),('push','mov','call','jmp')),
@@ -294,9 +294,9 @@ class ArchitectureX86_64(ArchitectureX86):
 
     def _initCategories(self):
         self._categories = {
-                gadget.Category.STACK_PIVOT : (('^mov (?P<dst>.sp), .+ ptr \[(?P<src>...)\]$','^mov (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>...), (?P<src>.sp)$','ret.+'),('push','mov','call','jmp')),
-                gadget.Category.LOAD_MEM : (('mov (?P<dst>r..), .+ ptr \[(?P<src>r..)\]',),('push','mov','call','jmp')),
-                gadget.Category.WRITE_MEM : (('^mov .+ ptr \[(?P<dst>r..)\], (?P<src>r..)$',),('push','mov','call','jmp')),
+                gadget.Category.STACK_PIVOT : ((r'^mov (?P<dst>.sp), .+ ptr \[(?P<src>...)\]$','^mov (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>.sp), (?P<src>...)$','^xchg (?P<dst>...), (?P<src>.sp)$','ret.+'),('push','mov','call','jmp')),
+                gadget.Category.LOAD_MEM : ((r'mov (?P<dst>r..), .+ ptr \[(?P<src>r..)\]',),('push','mov','call','jmp')),
+                gadget.Category.WRITE_MEM : ((r'^mov .+ ptr \[(?P<dst>r..)\], (?P<src>r..)$',),('push','mov','call','jmp')),
                 gadget.Category.LOAD_REG : (('pop (?P<dst>r..)',),('push','mov','call','jmp')),
                 gadget.Category.JMP : (('^jmp (?P<dst>r..)$',),()),
                 gadget.Category.CALL : (('^call (?P<dst>r..)$',),('push','mov','call','jmp')),
diff --git a/ropper/console.py b/ropper/console.py
index 1f75e78..0553b3a 100644
--- a/ropper/console.py
+++ b/ropper/console.py
@@ -736,7 +736,7 @@ nx\t- Clears the NX-Flag (ELF|PE)"""
         if len(text) == 0:
             self.help_search()
             return
-        match = re.match('/\d+/', text)
+        match = re.match(r'/\d+/', text)
         qual = None
         if match:
             qual = int(match.group(0)[1:-1])
diff --git a/ropper/rop.py b/ropper/rop.py
index 5e43a2c..87145cd 100644
--- a/ropper/rop.py
+++ b/ropper/rop.py
@@ -164,7 +164,7 @@ class Ropper(object):
             if opcode.find(b) % 2 == 0:
                 opcode = opcode.replace(b,b'%s%s' % (hexlify(b'\\'),b))
 
-        m = re.search(b'\?', opcode)
+        m = re.search(rb'\?', opcode)
         while m:
             if m.start() % 2 == 0:
                 char = opcode[m.start()+1]
@@ -184,7 +184,7 @@ class Ropper(object):
 
                 opcode = opcode[:m.start()-1] + hexlify(b'['+pack('B',start)+b'-'+pack('B',end)+b']') + opcode[m.start()+1:]
 
-            m = re.search(b'\?', opcode)
+            m = re.search(rb'\?', opcode)
         try:
 
             opcode = unhexlify(opcode)
diff --git a/ropper/search.py b/ropper/search.py
index 3c9aada..60460fd 100644
--- a/ropper/search.py
+++ b/ropper/search.py
@@ -43,7 +43,7 @@ import sys
 
 class Searcher(object):
 
-    CONSTRAINT_REGEX = '(\[?[a-zA-Z0-9]+\]?)([\+\*\-=/])?=(\[?[a-zA-Z0-9]+\]?)$'
+    CONSTRAINT_REGEX = r'(\[?[a-zA-Z0-9]+\]?)([\+\*\-=/])?=(\[?[a-zA-Z0-9]+\]?)$'
 
     def prepareFilter(self, filter):
         filter = filter.replace('\\','\\\\')
@@ -257,6 +257,6 @@ class SearcherMIPS(Searcher):
 
     def prepareFilter(self, filter):
         filter = super(SearcherMIPS, self).prepareFilter(filter)
-        filter = filter.replace('$','\$')
+        filter = filter.replace('$',r'\$')
 
         return filter
diff --git a/ropper/z3helper.py b/ropper/z3helper.py
index 55d1afd..a62160b 100644
--- a/ropper/z3helper.py
+++ b/ropper/z3helper.py
@@ -43,8 +43,8 @@ class ConstraintCompiler(object):
 
     NUMBER_REGEX = '(-?[0-9]+)'
     REG_REGEX = '(?P<{}>[a-zA-Z0-9]+)'
-    ADJUST_REGEX = '([\\+\-\*/=]=)'
-    ASSIGNMENT_REGEX = '('+REG_REGEX.format('reg_dst_1') + ' *' + ADJUST_REGEX + ' *('+NUMBER_REGEX+'|'+REG_REGEX.format('reg_src_1')+'|(\[)'+REG_REGEX.format('reg_src_2')+'(\])))'
+    ADJUST_REGEX = r'([\\+\-\*/=]=)'
+    ASSIGNMENT_REGEX = '('+REG_REGEX.format('reg_dst_1') + ' *' + ADJUST_REGEX + ' *('+NUMBER_REGEX+'|'+REG_REGEX.format('reg_src_1')+r'|(\[)'+REG_REGEX.format('reg_src_2')+r'(\])))'
     POP_REGEX = '((pop) +'+REG_REGEX.format('reg_dst_2')+')'
     CONSTRAINT_REGEX = '(' + ASSIGNMENT_REGEX + '|' + POP_REGEX + ')'
 
diff --git a/testcases/test_general.py b/testcases/test_general.py
index 263c1d4..597d90d 100644
--- a/testcases/test_general.py
+++ b/testcases/test_general.py
@@ -84,7 +84,7 @@ class GeneralTests(unittest.TestCase):
 
         if version_info.major == 3 and version_info.minor >= 2:
             # Wrong question mark position
-            with self.assertRaisesRegex(RopperError,'A \? for the highest 4 bit of a byte is not supported.*'):
+            with self.assertRaisesRegex(RopperError,r'A \? for the highest 4 bit of a byte is not supported.*'):
                 self.rs.searchOpcode('ff?4')
             # Wrong lengh
             with self.assertRaisesRegex(RopperError,'The length of the opcode has to be a multiple of two'):
@@ -94,7 +94,7 @@ class GeneralTests(unittest.TestCase):
                 self.rs.searchOpcode('ff4r')
         else:
             # Wrong question mark position
-            with self.assertRaisesRegexp(RopperError,'A \? for the highest 4 bit of a byte is not supported.*'):
+            with self.assertRaisesRegexp(RopperError,r'A \? for the highest 4 bit of a byte is not supported.*'):
                 self.rs.searchOpcode('ff?4')
             # Wrong lengh
             with self.assertRaisesRegexp(RopperError,'The length of the opcode has to be a multiple of two'):