|
8 | 8 | import os |
9 | 9 |
|
10 | 10 | from lib.core.common import Backend |
| 11 | +from lib.core.common import getSafeExString |
11 | 12 | from lib.core.common import isStackingAvailable |
12 | 13 | from lib.core.common import readInput |
13 | 14 | from lib.core.common import runningAsAdmin |
|
20 | 21 | from lib.core.exception import SqlmapMissingMandatoryOptionException |
21 | 22 | from lib.core.exception import SqlmapMissingPrivileges |
22 | 23 | from lib.core.exception import SqlmapNotVulnerableException |
| 24 | +from lib.core.exception import SqlmapSystemException |
23 | 25 | from lib.core.exception import SqlmapUndefinedMethod |
24 | 26 | from lib.core.exception import SqlmapUnsupportedDBMSException |
25 | 27 | from lib.takeover.abstraction import Abstraction |
@@ -132,12 +134,16 @@ def osPwn(self): |
132 | 134 | errMsg += "http://code.google.com/p/impacket/downloads/list" |
133 | 135 | raise SqlmapMissingDependence(errMsg) |
134 | 136 |
|
135 | | - sysIgnoreIcmp = "/proc/sys/net/ipv4/icmp_echo_ignore_all" |
| 137 | + filename = "/proc/sys/net/ipv4/icmp_echo_ignore_all" |
136 | 138 |
|
137 | | - if os.path.exists(sysIgnoreIcmp): |
138 | | - fp = open(sysIgnoreIcmp, "wb") |
139 | | - fp.write("1") |
140 | | - fp.close() |
| 139 | + if os.path.exists(filename): |
| 140 | + try: |
| 141 | + with open(filename, "wb") as f: |
| 142 | + f.write("1") |
| 143 | + except IOError, ex: |
| 144 | + errMsg = "there has been a file opening/writing error " |
| 145 | + errMsg += "for filename '%s' ('%s')" % (filename, getSafeExString(ex)) |
| 146 | + raise SqlmapSystemException(errMsg) |
141 | 147 | else: |
142 | 148 | errMsg = "you need to disable ICMP replies by your machine " |
143 | 149 | errMsg += "system-wide. For example run on Linux/Unix:\n" |
|
0 commit comments