-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect-to-routers-anonymously-9287ec7e7951.html
305 lines (234 loc) · 15.9 KB
/
connect-to-routers-anonymously-9287ec7e7951.html
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="" />
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,700;1,400&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./theme/stylesheet/style.min.css">
<link id="pygments-light-theme" rel="stylesheet" type="text/css"
href="./theme/pygments/github.min.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/fontawesome.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/brands.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/solid.css">
<link href="https://shanedowling.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Shane Dowling Atom">
<link href="https://shanedowling.com/feeds/all.rss.xml" type="application/rss+xml" rel="alternate" title="Shane Dowling RSS">
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'G-Z9P3V6D0SV', 'auto');
ga('send', 'pageview');
</script>
<meta name="author" content="Shane Dowling" />
<meta name="description" content="I've created a little script that incorporates wicd, macchanger, hostname and john the ripper's password list to randomise your mac address and hostname when connecting to the internet. I've gone with wicd over network manager as network-manager has a tendency to store connection details, so while your machine might id …" />
<meta name="keywords" content="">
<meta property="og:site_name" content="Shane Dowling"/>
<meta property="og:title" content="Connect to routers anonymously"/>
<meta property="og:description" content="I've created a little script that incorporates wicd, macchanger, hostname and john the ripper's password list to randomise your mac address and hostname when connecting to the internet. I've gone with wicd over network manager as network-manager has a tendency to store connection details, so while your machine might id …"/>
<meta property="og:locale" content="en_US"/>
<meta property="og:url" content="./connect-to-routers-anonymously-9287ec7e7951.html"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="2013-09-28 00:00:00+00:00"/>
<meta property="article:modified_time" content=""/>
<meta property="article:author" content="./author/shane-dowling.html">
<meta property="article:section" content="Tech"/>
<meta property="og:image" content="/images/logo.png">
<title>Shane Dowling – Connect to routers anonymously</title>
</head>
<body class="light-theme">
<aside>
<div>
<a href="./">
<img src="/images/logo.png" alt="Shane Dowling" title="Shane Dowling">
</a>
<h1>
<a href="./">Shane Dowling</a>
</h1>
<p>Platform Engineering Manager</p>
<nav>
<ul class="list">
<li>
<a target="_self"
href="./pages/contact.html#contact">
Contact
</a>
</li>
<li>
<a target="_self"
href="./pages/now-page.html#now-page">
Now Page
</a>
</li>
<li>
<a target="_self"
href="./pages/statuslog.html#statuslog">
Statuslog
</a>
</li>
<li>
<a target="_self" href="https://hybridcloudshow.com/" >podcast</a>
</li>
<li>
<a target="_self" href="https://pemonthly.com/" >newsletter</a>
</li>
</ul>
</nav>
<ul class="social">
<li>
<a class="sc-github"
href="http://github.com/shano"
target="_blank">
<i class="fa-brands fa-github"></i>
</a>
</li>
<li>
<a class="sc-mastodon"
rel="me" href="http://social.lol/@sed"
target="_blank">
<i class="fa-brands fa-mastodon"></i>
</a>
</li>
<li>
<a class="sc-linkedin"
href="https://www.linkedin.com/in/shanedow/"
target="_blank">
<i class="fa-brands fa-linkedin"></i>
</a>
</li>
</ul>
</div>
</aside>
<main>
<article class="single">
<header>
<h1 id="connect-to-routers-anonymously-9287ec7e7951">Connect to routers anonymously</h1>
<p>
Posted on Sat 28 September 2013 in <a href="./category/tech.html">Tech</a>
</p>
</header>
<div>
<p><img alt="" src="images/1__2zYJ6QvnP__Z17B321DD7NQ.png"></p>
<p>I've created a little script that incorporates
<a href="https://launchpad.net/wicd">wicd</a>, <a href="https://github.com/alobbs/macchanger">macchanger</a>, <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?hostname">hostname</a> and <a href="http://www.openwall.com/john/">john the ripper's</a> password list to randomise your mac address and hostname when connecting to the internet.</p>
<p>I've gone with wicd over network manager as network-manager has a
tendency to store connection details, so while your machine might id
your hostname or mac address as something new, network-manager will
actually connect using the original stored details.</p>
<p>I must admit I enjoyed writing this, it reminded me of the old days when
linux network managers were all rubbish and you had to write bash
scripts to connect to vaguely complex network configurations.</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/bin/bash</span>
<span class="w"> </span><span class="c1"># Anonymise your machines internet connection</span>
<span class="c1"># Settings</span>
<span class="w"> </span><span class="nv">INTERFACE</span><span class="o">=</span>wlan1
<span class="w"> </span><span class="nv">HOSTS_FILE</span><span class="o">=</span><span class="s2">"/etc/hosts"</span>
<span class="w"> </span><span class="nv">START_TOKEN</span><span class="o">=</span><span class="s2">"## start-anon"</span>
<span class="w"> </span><span class="nv">END_TOKEN</span><span class="o">=</span><span class="s2">"## end-anon"</span>
<span class="c1"># Must be run as root</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="o">[[</span><span class="w"> </span><span class="nv">$EUID</span><span class="w"> </span>-ne<span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="o">]]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"This script must be run as root\\n"</span><span class="w"> </span><span class="m">1</span>><span class="p">&</span><span class="m">2</span>
<span class="w"> </span><span class="nb">exit</span><span class="w"> </span><span class="m">1</span>
<span class="w"> </span><span class="k">fi</span>
<span class="c1"># Network restart function</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"Linux"</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="se">\`</span>uname<span class="se">\`</span><span class="w"> </span><span class="o">]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w"> </span><span class="nv">restart_network</span><span class="o">=</span><span class="s2">"/etc/init.d/networking restart"</span>
<span class="w"> </span><span class="k">fi</span>
<span class="c1"># Function to clear old data and add new hosts entry</span>
<span class="w"> </span><span class="k">function</span><span class="w"> </span>update_hosts<span class="o">()</span>
<span class="w"> </span><span class="o">{</span>
<span class="w"> </span><span class="c1"># if no hosts file found…</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span>!<span class="w"> </span>-f<span class="w"> </span><span class="nv">$1</span><span class="w"> </span><span class="o">]</span>
<span class="w"> </span><span class="k">then</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="se">\\</span>n<span class="s2">"No hosts file found\\n"</span><span class="w"> </span><span class="m">1</span>><span class="p">&</span><span class="m">2</span>
<span class="w"> </span><span class="nb">exit</span><span class="w"> </span><span class="m">1</span>
<span class="w"> </span><span class="k">fi</span>
<span class="nv">file</span><span class="o">=</span><span class="nv">$1</span>
<span class="w"> </span><span class="nv">host</span><span class="o">=</span><span class="nv">$2</span>
<span class="nv">sed_script</span><span class="o">=</span><span class="s2">"{</span>
<span class="s2"> s/</span><span class="nv">$END_TOKEN</span><span class="s2">/</span><span class="nv">$END_TOKEN</span><span class="s2">/</span>
<span class="s2"> t finished_sites</span>
<span class="s2">s/</span><span class="nv">$START_TOKEN</span><span class="s2">/</span><span class="nv">$START_TOKEN</span><span class="s2">/</span>
<span class="s2"> x</span>
<span class="s2"> t started_sites</span>
<span class="s2">s/</span><span class="nv">$START_TOKEN</span><span class="s2">/</span><span class="nv">$START_TOKEN</span><span class="s2">/</span>
<span class="s2"> x</span>
<span class="s2"> t started_sites</span>
<span class="s2">p</span>
<span class="s2"> b end</span>
<span class="s2"> : started_sites</span>
<span class="s2"> d</span>
<span class="s2"> : finished_sites</span>
<span class="s2"> x</span>
<span class="s2"> d</span>
<span class="s2"> : end</span>
<span class="s2"> d</span>
<span class="s2"> }"</span>
hostname<span class="w"> </span><span class="nv">$host</span>
sed<span class="w"> </span>—<span class="w"> </span><span class="k">in</span>-place<span class="w"> </span>-e<span class="w"> </span><span class="s2">"</span><span class="nv">$sed_script</span><span class="s2">"</span><span class="w"> </span><span class="nv">$file</span>
<span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="nv">$START_TOKEN</span><span class="w"> </span>>><span class="w"> </span><span class="nv">$file</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"\\n127.0.1.1 </span><span class="nv">$host</span><span class="s2">\\n"</span><span class="w"> </span>>><span class="w"> </span><span class="nv">$file</span>
<span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="nv">$END_TOKEN</span><span class="w"> </span>>><span class="w"> </span><span class="nv">$file</span>
<span class="w"> </span><span class="o">}</span>
<span class="c1"># Presenting original information</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"Starting to anonimise your data\\n"</span>
<span class="c1"># Stop Wicd</span>
<span class="w"> </span>sudo<span class="w"> </span>service<span class="w"> </span>wicd<span class="w"> </span>stop
<span class="w"> </span>sleep<span class="w"> </span><span class="m">1</span>
<span class="c1">#changing mac address to random</span>
<span class="w"> </span>ifconfig<span class="w"> </span><span class="nv">$INTERFACE</span><span class="w"> </span>down<span class="w"> </span>><span class="w"> </span>/dev/null
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="nv">$?</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="o">]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"%snChanging mac address…\\n"</span>
<span class="w"> </span>macchanger<span class="w"> </span>-r<span class="w"> </span><span class="nv">$INTERFACE</span>
<span class="w"> </span><span class="k">else</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"%sScript encountered an error, sorry…\\n"</span>
<span class="w"> </span><span class="nb">exit</span><span class="w"> </span><span class="m">1</span>
<span class="w"> </span><span class="k">fi</span>
<span class="w"> </span>sleep<span class="w"> </span><span class="m">1</span>
<span class="c1"># Use john to supply new hostname to function</span>
<span class="w"> </span><span class="nv">OLDHOST</span><span class="o">=</span><span class="k">$(</span>hostname<span class="k">)</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"%s\\nChanging hostname…\\n"</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"Current : </span><span class="nv">$OLDHOST</span><span class="s2"> \\n"</span>
<span class="w"> </span><span class="nv">FILE</span><span class="o">=</span>/usr/share/john/password.lst
<span class="w"> </span><span class="nv">WORD</span><span class="o">=</span><span class="k">$(</span>sort<span class="w"> </span>-R<span class="w"> </span><span class="nv">$FILE</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>head<span class="w"> </span>-1<span class="k">)</span>
<span class="w"> </span>update_hosts<span class="w"> </span><span class="nv">$HOSTS_FILE</span><span class="w"> </span><span class="nv">$WORD</span>
<span class="w"> </span><span class="nv">NEWHOST</span><span class="o">=</span><span class="k">$(</span>hostname<span class="k">)</span>
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"New : </span><span class="nv">$NEWHOST</span><span class="s2"> \\n"</span>
<span class="w"> </span>sleep<span class="w"> </span><span class="m">1</span>
<span class="c1"># putting interface up</span>
<span class="w"> </span>ifconfig<span class="w"> </span><span class="nv">$INTERFACE</span><span class="w"> </span>up<span class="w"> </span>><span class="w"> </span>/dev/null
<span class="w"> </span><span class="nb">printf</span><span class="w"> </span><span class="s2">"\\n"</span>
<span class="w"> </span>sleep<span class="w"> </span><span class="m">1</span>
<span class="c1"># Restart networking</span>
<span class="w"> </span><span class="nv">$restart_network</span>
<span class="c1"># Get wicd back up and running</span>
<span class="w"> </span>service<span class="w"> </span>wicd<span class="w"> </span>start
<span class="w"> </span>sleep<span class="w"> </span><span class="m">1</span>
wicd-gtk<span class="w"> </span>><span class="w"> </span>/dev/null<span class="w"> </span><span class="m">2</span>><span class="p">&</span><span class="m">1</span><span class="w"> </span><span class="p">&</span>
</code></pre></div>
</div>
<div class="tag-cloud">
<p>
</p>
</div>
</article>
<footer>
<p>© </p>
<p>
Built with <a href="http://getpelican.com" target="_blank">Pelican</a> using <a href="http://bit.ly/flex-pelican" target="_blank">Flex</a> theme
</p></footer> </main>
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Blog",
"name": " Shane Dowling ",
"url" : ".",
"image": "/images/logo.png",
"description": ""
}
</script>
</body>
</html>