PageRenderTime 35ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/volatility/plugins/overlays/windows/tcpip_vtypes.py

http://volatility.googlecode.com/
Python | 331 lines | 290 code | 15 blank | 26 comment | 0 complexity | 97e1e17e9628c490e48a628ad817787f MD5 | raw file
Possible License(s): AGPL-1.0
  1. # Volatility
  2. #
  3. # This file is part of Volatility.
  4. #
  5. # Volatility is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Volatility is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with Volatility. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. import volatility.obj as obj
  19. # Structures used by connections, connscan, sockets, sockscan.
  20. # Used by x86 XP (all service packs) and x86 2003 SP0.
  21. tcpip_vtypes = {
  22. '_ADDRESS_OBJECT' : [ 0x68, {
  23. 'Next' : [ 0x0, ['pointer', ['_ADDRESS_OBJECT']]],
  24. 'LocalIpAddress' : [ 0x2c, ['IpAddress']],
  25. 'LocalPort' : [ 0x30, ['unsigned be short']],
  26. 'Protocol' : [ 0x32, ['unsigned short']],
  27. 'Pid' : [ 0x148, ['unsigned long']],
  28. 'CreateTime' : [ 0x158, ['WinTimeStamp', dict(is_utc = True)]],
  29. }],
  30. '_TCPT_OBJECT' : [ 0x20, {
  31. 'Next' : [ 0x0, ['pointer', ['_TCPT_OBJECT']]],
  32. 'RemoteIpAddress' : [ 0xc, ['IpAddress']],
  33. 'LocalIpAddress' : [ 0x10, ['IpAddress']],
  34. 'RemotePort' : [ 0x14, ['unsigned be short']],
  35. 'LocalPort' : [ 0x16, ['unsigned be short']],
  36. 'Pid' : [ 0x18, ['unsigned long']],
  37. }],
  38. }
  39. # Structures used by connections, connscan, sockets, sockscan.
  40. # Used by x64 XP and x64 2003 (all service packs).
  41. tcpip_vtypes_2003_x64 = {
  42. '_ADDRESS_OBJECT' : [ None, {
  43. 'Next' : [ 0x0, ['pointer', ['_ADDRESS_OBJECT']]],
  44. 'LocalIpAddress' : [ 0x58, ['IpAddress']],
  45. 'LocalPort' : [ 0x5c, ['unsigned be short']],
  46. 'Protocol' : [ 0x5e, ['unsigned short']],
  47. 'Pid' : [ 0x238, ['unsigned long']],
  48. 'CreateTime' : [ 0x248, ['WinTimeStamp', dict(is_utc = True)]],
  49. }],
  50. '_TCPT_OBJECT' : [ None, {
  51. 'Next' : [ 0x0, ['pointer', ['_TCPT_OBJECT']]],
  52. 'RemoteIpAddress' : [ 0x14, ['IpAddress']],
  53. 'LocalIpAddress' : [ 0x18, ['IpAddress']],
  54. 'RemotePort' : [ 0x1c, ['unsigned be short']],
  55. 'LocalPort' : [ 0x1e, ['unsigned be short']],
  56. 'Pid' : [ 0x20, ['unsigned long']],
  57. }],
  58. }
  59. # Structures used by sockets and sockscan.
  60. # Used by x86 2003 SP1 and SP2 only.
  61. tcpip_vtypes_2003_sp1_sp2 = {
  62. '_ADDRESS_OBJECT' : [ 0x68, {
  63. 'Next' : [ 0x0, ['pointer', ['_ADDRESS_OBJECT']]],
  64. 'LocalIpAddress' : [ 0x30, ['IpAddress']],
  65. 'LocalPort' : [ 0x34, ['unsigned be short']],
  66. 'Protocol' : [ 0x36, ['unsigned short']],
  67. 'Pid' : [ 0x14C, ['unsigned long']],
  68. 'CreateTime' : [ 0x158, ['WinTimeStamp', dict(is_utc = True)]],
  69. }],
  70. }
  71. TCP_STATE_ENUM = {
  72. 0: 'CLOSED', 1: 'LISTENING', 2: 'SYN_SENT',
  73. 3: 'SYN_RCVD', 4: 'ESTABLISHED', 5: 'FIN_WAIT1',
  74. 6: 'FIN_WAIT2', 7: 'CLOSE_WAIT', 8: 'CLOSING',
  75. 9: 'LAST_ACK', 12: 'TIME_WAIT', 13: 'DELETE_TCB'
  76. }
  77. # Structures used by netscan for x86 Vista and 2008 (all service packs).
  78. tcpip_vtypes_vista = {
  79. '_IN_ADDR' : [ None, {
  80. 'addr4' : [ 0x0, ['IpAddress']],
  81. 'addr6' : [ 0x0, ['Ipv6Address']],
  82. }],
  83. '_LOCAL_ADDRESS' : [ None, {
  84. 'pData' : [ 0xC, ['pointer', ['pointer', ['_IN_ADDR']]]],
  85. }],
  86. '_TCP_LISTENER': [ None, { # TcpL
  87. 'Owner' : [ 0x18, ['pointer', ['_EPROCESS']]],
  88. 'CreateTime' : [ 0x20, ['WinTimeStamp', dict(is_utc = True)]],
  89. 'LocalAddr' : [ 0x34, ['pointer', ['_LOCAL_ADDRESS']]],
  90. 'InetAF' : [ 0x38, ['pointer', ['_INETAF']]],
  91. 'Port' : [ 0x3E, ['unsigned be short']],
  92. }],
  93. '_TCP_ENDPOINT': [ None, { # TcpE
  94. 'InetAF' : [ 0xC, ['pointer', ['_INETAF']]],
  95. 'AddrInfo' : [ 0x10, ['pointer', ['_ADDRINFO']]],
  96. 'ListEntry': [ 0x14, ['_LIST_ENTRY']],
  97. 'State' : [ 0x28, ['Enumeration', dict(target = 'long', choices = TCP_STATE_ENUM)]],
  98. 'LocalPort' : [ 0x2C, ['unsigned be short']],
  99. 'RemotePort' : [ 0x2E, ['unsigned be short']],
  100. 'Owner' : [ 0x160, ['pointer', ['_EPROCESS']]],
  101. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  102. }],
  103. '_TCP_SYN_ENDPOINT': [ None, {
  104. 'ListEntry': [ 8, ['_LIST_ENTRY']],
  105. 'InetAF' : [ 0x18, ['pointer', ['_INETAF']]],
  106. 'LocalPort' : [ 0x3c, ['unsigned be short']],
  107. 'RemotePort' : [ 0x3e, ['unsigned be short']],
  108. 'LocalAddr' : [ 0x1c, ['pointer', ['_LOCAL_ADDRESS']]],
  109. 'RemoteAddress' : [ 0x28, ['pointer', ['_IN_ADDR']]],
  110. 'Owner' : [ 0x20, ['pointer', ['_SYN_OWNER']]],
  111. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  112. }],
  113. '_SYN_OWNER': [ None, {
  114. 'Process': [ 0x18, ['pointer', ['_EPROCESS']]],
  115. }],
  116. '_TCP_TIMEWAIT_ENDPOINT': [ None, {
  117. 'ListEntry': [ 0x14, ['_LIST_ENTRY']],
  118. 'InetAF' : [ 0xc, ['pointer', ['_INETAF']]],
  119. 'LocalPort' : [ 0x1c, ['unsigned be short']],
  120. 'RemotePort' : [ 0x1e, ['unsigned be short']],
  121. 'LocalAddr' : [ 0x20, ['pointer', ['_LOCAL_ADDRESS']]],
  122. 'RemoteAddress' : [ 0x24, ['pointer', ['_IN_ADDR']]],
  123. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  124. }],
  125. '_INETAF' : [ None, {
  126. 'AddressFamily' : [ 0xC, ['unsigned short']],
  127. }],
  128. '_ADDRINFO' : [ None, {
  129. 'Local' : [ 0x0, ['pointer', ['_LOCAL_ADDRESS']]],
  130. 'Remote' : [ 0x8, ['pointer', ['_IN_ADDR']]],
  131. }],
  132. '_UDP_ENDPOINT': [ None, { # UdpA
  133. 'Owner' : [ 0x18, ['pointer', ['_EPROCESS']]],
  134. 'CreateTime' : [ 0x30, ['WinTimeStamp', dict(is_utc = True)]],
  135. 'LocalAddr' : [ 0x38, ['pointer', ['_LOCAL_ADDRESS']]],
  136. 'InetAF' : [ 0x14, ['pointer', ['_INETAF']]],
  137. 'Port' : [ 0x48, ['unsigned be short']],
  138. }],
  139. }
  140. # Structures for netscan on x86 Windows 7 (all service packs).
  141. tcpip_vtypes_7 = {
  142. '_TCP_ENDPOINT': [ None, { # TcpE
  143. 'InetAF' : [ 0xC, ['pointer', ['_INETAF']]],
  144. 'AddrInfo' : [ 0x10, ['pointer', ['_ADDRINFO']]],
  145. 'ListEntry': [ 0x14, ['_LIST_ENTRY']],
  146. 'State' : [ 0x34, ['Enumeration', dict(target = 'long', choices = TCP_STATE_ENUM)]],
  147. 'LocalPort' : [ 0x38, ['unsigned be short']],
  148. 'RemotePort' : [ 0x3A, ['unsigned be short']],
  149. 'Owner' : [ 0x174, ['pointer', ['_EPROCESS']]],
  150. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  151. }],
  152. '_TCP_SYN_ENDPOINT': [ None, {
  153. 'ListEntry': [ 8, ['_LIST_ENTRY']],
  154. 'InetAF' : [ 0x24, ['pointer', ['_INETAF']]],
  155. 'LocalPort' : [ 0x48, ['unsigned be short']],
  156. 'RemotePort' : [ 0x4a, ['unsigned be short']],
  157. 'LocalAddr' : [ 0x28, ['pointer', ['_LOCAL_ADDRESS']]],
  158. 'RemoteAddress' : [ 0x34, ['pointer', ['_IN_ADDR']]],
  159. 'Owner' : [ 0x2c, ['pointer', ['_SYN_OWNER']]],
  160. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  161. }],
  162. '_TCP_TIMEWAIT_ENDPOINT': [ None, {
  163. 'ListEntry': [ 0, ['_LIST_ENTRY']],
  164. 'InetAF' : [ 0x18, ['pointer', ['_INETAF']]],
  165. 'LocalPort' : [ 0x28, ['unsigned be short']],
  166. 'RemotePort' : [ 0x2a, ['unsigned be short']],
  167. 'LocalAddr' : [ 0x2c, ['pointer', ['_LOCAL_ADDRESS']]],
  168. 'RemoteAddress' : [ 0x30, ['pointer', ['_IN_ADDR']]],
  169. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  170. }],
  171. }
  172. # Structures for netscan on x64 Vista SP0 and 2008 SP0
  173. tcpip_vtypes_vista_64 = {
  174. '_IN_ADDR' : [ None, {
  175. 'addr4' : [ 0x0, ['IpAddress']],
  176. 'addr6' : [ 0x0, ['Ipv6Address']],
  177. }],
  178. '_TCP_LISTENER': [ None, { # TcpL
  179. 'Owner' : [ 0x28, ['pointer', ['_EPROCESS']]],
  180. 'CreateTime' : [ 0x20, ['WinTimeStamp', dict(is_utc = True)]],
  181. 'LocalAddr' : [ 0x58, ['pointer', ['_LOCAL_ADDRESS']]],
  182. 'InetAF' : [ 0x60, ['pointer', ['_INETAF']]],
  183. 'Port' : [ 0x6a, ['unsigned be short']],
  184. }],
  185. '_INETAF' : [ None, {
  186. 'AddressFamily' : [ 0x14, ['unsigned short']],
  187. }],
  188. '_LOCAL_ADDRESS' : [ None, {
  189. 'pData' : [ 0x10, ['pointer', ['pointer', ['_IN_ADDR']]]],
  190. }],
  191. '_ADDRINFO' : [ None, {
  192. 'Local' : [ 0x0, ['pointer', ['_LOCAL_ADDRESS']]],
  193. 'Remote' : [ 0x10, ['pointer', ['_IN_ADDR']]],
  194. }],
  195. '_TCP_ENDPOINT': [ None, { # TcpE
  196. 'InetAF' : [ 0x18, ['pointer', ['_INETAF']]],
  197. 'AddrInfo' : [ 0x20, ['pointer', ['_ADDRINFO']]],
  198. 'ListEntry': [ 0x28, ['_LIST_ENTRY']],
  199. 'State' : [ 0x50, ['Enumeration', dict(target = 'long', choices = TCP_STATE_ENUM)]],
  200. 'LocalPort' : [ 0x54, ['unsigned be short']],
  201. 'RemotePort' : [ 0x56, ['unsigned be short']],
  202. 'Owner' : [ 0x208, ['pointer', ['_EPROCESS']]],
  203. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  204. }],
  205. '_TCP_SYN_ENDPOINT': [ None, {
  206. 'ListEntry': [ 0x10, ['_LIST_ENTRY']],
  207. 'InetAF' : [ 0x30, ['pointer', ['_INETAF']]],
  208. 'LocalPort' : [ 0x64, ['unsigned be short']],
  209. 'RemotePort' : [ 0x66, ['unsigned be short']],
  210. 'LocalAddr' : [ 0x38, ['pointer', ['_LOCAL_ADDRESS']]],
  211. 'RemoteAddress' : [ 0x50, ['pointer', ['_IN_ADDR']]],
  212. 'Owner' : [ 0x40, ['pointer', ['_SYN_OWNER']]],
  213. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  214. }],
  215. '_SYN_OWNER': [ None, {
  216. 'Process': [ 0x28, ['pointer', ['_EPROCESS']]],
  217. }],
  218. '_TCP_TIMEWAIT_ENDPOINT': [ None, {
  219. 'ListEntry': [ 0, ['_LIST_ENTRY']],
  220. 'InetAF' : [ 0x18, ['pointer', ['_INETAF']]],
  221. 'LocalPort' : [ 0x30, ['unsigned be short']],
  222. 'RemotePort' : [ 0x32, ['unsigned be short']],
  223. 'LocalAddr' : [ 0x38, ['pointer', ['_LOCAL_ADDRESS']]],
  224. 'RemoteAddress' : [ 0x40, ['pointer', ['_IN_ADDR']]],
  225. 'CreateTime' : [ 0, ['WinTimeStamp', dict(value = 0, is_utc = True)]],
  226. }],
  227. '_UDP_ENDPOINT': [ None, { # UdpA
  228. 'Owner' : [ 0x28, ['pointer', ['_EPROCESS']]],
  229. 'CreateTime' : [ 0x58, ['WinTimeStamp', dict(is_utc = True)]],
  230. 'LocalAddr' : [ 0x60, ['pointer', ['_LOCAL_ADDRESS']]],
  231. 'InetAF' : [ 0x20, ['pointer', ['_INETAF']]],
  232. 'Port' : [ 0x80, ['unsigned be short']],
  233. }],
  234. }
  235. class WinXP2003Tcpipx64(obj.ProfileModification):
  236. before = ['WindowsVTypes']
  237. conditions = {'os': lambda x: x == 'windows',
  238. 'memory_model': lambda x: x == '64bit',
  239. 'major': lambda x : x == 5,
  240. 'minor': lambda x : x == 2}
  241. def modification(self, profile):
  242. profile.vtypes.update(tcpip_vtypes_2003_x64)
  243. class Win2003SP12Tcpip(obj.ProfileModification):
  244. before = ['WindowsVTypes']
  245. conditions = {'os': lambda x: x == 'windows',
  246. 'memory_model': lambda x: x == '32bit',
  247. 'major': lambda x : x == 5,
  248. 'minor': lambda x : x == 2,
  249. 'build': lambda x : x != 3789}
  250. def modification(self, profile):
  251. profile.vtypes.update(tcpip_vtypes_2003_sp1_sp2)
  252. class Vista2008Tcpip(obj.ProfileModification):
  253. conditions = {'os': lambda x: x == 'windows',
  254. 'memory_model': lambda x: x == '32bit',
  255. 'major': lambda x : x == 6,
  256. 'minor': lambda x : x >= 0}
  257. def modification(self, profile):
  258. profile.vtypes.update(tcpip_vtypes_vista)
  259. class Win7Tcpip(obj.ProfileModification):
  260. before = ['Vista2008Tcpip']
  261. conditions = {'os': lambda x: x == 'windows',
  262. 'memory_model': lambda x: x == '32bit',
  263. 'major': lambda x : x == 6,
  264. 'minor': lambda x : x == 1}
  265. def modification(self, profile):
  266. profile.vtypes.update(tcpip_vtypes_7)
  267. class Win7Vista2008x64Tcpip(obj.ProfileModification):
  268. conditions = {'os': lambda x: x == 'windows',
  269. 'memory_model': lambda x: x == '64bit',
  270. 'major': lambda x : x == 6,
  271. 'minor': lambda x : x >= 0}
  272. def modification(self, profile):
  273. profile.vtypes.update(tcpip_vtypes_vista_64)
  274. class VistaSP12x64Tcpip(obj.ProfileModification):
  275. before = ['Win7Vista2008x64Tcpip']
  276. conditions = {'os': lambda x: x == 'windows',
  277. 'memory_model': lambda x: x == '64bit',
  278. 'major': lambda x : x == 6,
  279. 'minor': lambda x : x == 0,
  280. 'build': lambda x : x >= 6001}
  281. def modification(self, profile):
  282. profile.merge_overlay({
  283. '_TCP_ENDPOINT': [ None, {
  284. 'Owner' : [ 0x210, ['pointer', ['_EPROCESS']]],
  285. }],
  286. })
  287. class Win7x64Tcpip(obj.ProfileModification):
  288. before = ['Win7Vista2008x64Tcpip']
  289. conditions = {'os': lambda x: x == 'windows',
  290. 'memory_model': lambda x: x == '64bit',
  291. 'major': lambda x : x == 6,
  292. 'minor': lambda x : x == 1}
  293. def modification(self, profile):
  294. profile.merge_overlay({
  295. '_TCP_ENDPOINT': [ None, {
  296. 'State' : [ 0x68, ['Enumeration', dict(target = 'long', choices = TCP_STATE_ENUM)]],
  297. 'LocalPort' : [ 0x6c, ['unsigned be short']],
  298. 'RemotePort' : [ 0x6e, ['unsigned be short']],
  299. 'Owner' : [ 0x238, ['pointer', ['_EPROCESS']]],
  300. }],
  301. '_TCP_SYN_ENDPOINT': [ None, {
  302. 'InetAF' : [ 0x48, ['pointer', ['_INETAF']]],
  303. 'LocalPort' : [ 0x7c, ['unsigned be short']],
  304. 'RemotePort' : [ 0x7e, ['unsigned be short']],
  305. 'LocalAddr' : [ 0x50, ['pointer', ['_LOCAL_ADDRESS']]],
  306. 'RemoteAddress' : [ 0x68, ['pointer', ['_IN_ADDR']]],
  307. 'Owner' : [ 0x58, ['pointer', ['_SYN_OWNER']]],
  308. }],
  309. '_TCP_TIMEWAIT_ENDPOINT': [ None, {
  310. 'InetAF' : [ 0x30, ['pointer', ['_INETAF']]],
  311. 'LocalPort' : [ 0x48, ['unsigned be short']],
  312. 'RemotePort' : [ 0x4a, ['unsigned be short']],
  313. 'LocalAddr' : [ 0x50, ['pointer', ['_LOCAL_ADDRESS']]],
  314. 'RemoteAddress' : [ 0x58, ['pointer', ['_IN_ADDR']]],
  315. }],
  316. })