Advertisement
Guest User

onion-mail v.0.2

a guest
Mar 5th, 2014
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.96 KB | None | 0 0
  1. magnet:?xt=urn:btih:eb0506f42860ee5605f62fa0adb83f10230a1bd5
  2.  
  3. ## 02.03.2014 (Sunday)
  4. ## Version 0.2
  5. ## updated: 05.03.2014 (Wednesday)
  6. ## for questions / additions goto: http://zw3crggtadila2sg.onion security
  7. ## board: subject @onion email (clear abuse but maybe it will go down in history as the
  8. ## birthplace of individual omail and the demise of gmail, hotmail, ymail, etc.)
  9. ## mailto: dopey1@ff6d7yz7hdw5xoav.onion
  10.  
  11. [start]howto: make a @onion "e"mail -aka- omail!
  12.  
  13. This is a howto for Linux.openSUSE (12.3) to make a "e"mail address with a onion domain name.
  14. It will allow to send to other @onion "e"mail address and receive "e"mails at a @onion
  15. domain DIRECTLY! To any computer on th planet connected to the internet and running tor!
  16. No registration, monies, paper work required. Plug-in and start omailing!
  17.  
  18. Requirements are two computers (or two virtualmachines).
  19. One computer will run "postfix" and the other will run "tor".
  20. Both computers need a network card/access *duh*.
  21. I'm sure it can be "mined" for relevant information for other distros : )
  22.  
  23. Lines with a ">" are considered command-line.
  24. Everything here should be executed as root (or lots of "sudo").
  25. Don't forget to logout after you're finished.
  26. Maybe read it once before?
  27.  
  28. DISCLAIMER? none. well one: make this howto better/easier not worse, else: copy away!
  29.  
  30. ===
  31. tor.system
  32. ===
  33. Use "yast > network > network devices" to configure the system:
  34. ip:192.168.0.2/24
  35. hostname: torserver
  36. site:site
  37. default gateway: 192.168.0.1 (real default gateway / ip of router!)
  38. dns server: 127.0.0.1
  39.  
  40. Also check and edit file "/etc/resolv.conf" to:
  41. nameserver 127.0.0.1
  42.  
  43. ===
  44. tor.system: tor.configuration
  45. ===
  46. link: https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy
  47. Use "yast > software > software management" to search/install "tor".
  48.  
  49. Make a directory for "tor":
  50. >mkdir /tor
  51.  
  52. And another one for the hidden "postfix" service:
  53. >mkdir /tor/hidden_service_postfix
  54.  
  55. Change owner to "tor":
  56. >chown -R tor:users /tor
  57. And:
  58. >chmod -R 0700 /tor
  59.  
  60. Edit file "/etc/tor/torrc" to:
  61. NickName Somenickname
  62. ContactInfo surprise@inter.net *Can be changed later to the created @onion "e"mail*
  63. ORport 192.168.0.2:8080
  64. BandwidthRate 30 KB
  65.  
  66. SOCKSport 192.168.0.2:11111
  67. SOCKSpolicy accept 192.168.0.0/24
  68. SOCKSpolicy accept 127.0.0.1
  69. SOCKSpolicy reject *
  70.  
  71. DNSport 192.168.0.2:5300
  72. DNSport 127.0.0.1:53
  73.  
  74. ExitPolicy reject *:*
  75.  
  76. ServerDNSresolvConffile /etc/tor/resolv.conf.tor
  77.  
  78. TRANSport 192.168.0.2:8081
  79. VirtualAddrNetwork 10.192.0.0/10
  80. AutoMapHostOnResolve 1
  81.  
  82. HiddenServiceDir /tor/hidden_service_postfix
  83. HiddenServicePort 25 192.168.0.25:25
  84.  
  85. Next edit file "/etc/tor/resolv.conf.tor" to some
  86. DNS servers you thrust (example link: http://www.opennicproject.org/):
  87. nameserver 106.186.17.181
  88. nameserver 118.88.20.195
  89.  
  90. Next edit file "/etc/sysconfig/SuSEfirewall2". Look for a line that starts
  91. with "FW_REDIRECT=" and change it to:
  92. FW_REDIRECT="192.168.0.0/24,192.168.0.2/24,udp,53,5300 192.168.0.25/24,10.192.0.0/10,tcp,25,8081"
  93.  
  94. Open firewall ports for "tcp:8080, tcp:8081, tcp:11111 udp:5300" in:
  95. "yast > security and users > firewall" in "Allowed services". Click on "Advanced".
  96. to recap:
  97. tcp:8080 is "ORport" (OnionRoutingPort) of tor
  98. tcp:8081 is "TRANSport" of tor (used for programs that don't know SOCKS)
  99. tcp:11111 is "SOCKSport" of tor (used by SOCKS enabled programs)
  100. udp:5300 is "DNSport" of tor-resolver
  101.  
  102. Don't forget to portforward the ORport (tcp:8080) from the internet facing
  103. device / router to 192.168.0.2.
  104.  
  105. Next start "tor": "YAST > SYSTEM > System Services (Runlevel)". Select the "tor" service
  106. and enable it (Remember this step: It can be used to start all further required servers in this how-to).
  107.  
  108. Execute "torctl log" in a terminal to see what's going on:
  109. >torctl log
  110.  
  111. If tor has logged in successfully to the tor-network then check the
  112. directory "/tor/hidden_service_postfix" for a file called "hostname".
  113. Open it to find your @onion name.
  114.  
  115. Example: 1234567890abcdef.onion (16 characters before ".onion"). This will be used as a
  116. placeholder in the further how-to. If you see it, rplace it with what you really (randomly) got : )
  117.  
  118. ===
  119. postfix.system (with dovecot, lighttpd + php5 + squirrelmail).
  120. ===
  121. ip:192.168.0.25/24
  122. default gateway: 192.168.0.2 (the ip of the "tor" running computer).
  123.  
  124. ***note: maybe a "route add -net 10.192.0.0 netmask 255.255.255.0 gw 192.168.0.2 dev eth0" will
  125. work instead? Might leak away if "route add" used wrong?***
  126.  
  127. hostname = 1234567890abcdef (see file mentioned above on the tor.system:"/tor/hidden_service_postfix/hostname")
  128. site/domain = onion
  129. dns server = 192.168.0.2 (tor-server ip)
  130.  
  131. Also check and edit (if required) file "/etc/resolv.conf" to:
  132. nameserver 192.168.0.2
  133.  
  134. ===
  135. postfix.system: postfix.configuration
  136. ===
  137. link: http://www.postfix.org/
  138.  
  139. Use "yast > software > software management" to search/install "postfix".
  140.  
  141. Use "yast > security and users > users and group management" to create a (omail) user.
  142. The name you create here will be the name before the "@"sign.
  143. Example: creating a user "bob" will then give a omail address of "bob@1234567890abcdef.onion"
  144.  
  145. Next we edit *sigh* file "/etc/postfix/main.cf" to include:
  146. inet_protocols = ipv4
  147. inet_interfaces = 127.0.0.1 192.168.0.25
  148.  
  149. ***note: above sayz where postfix will bind to and listen for incoming mail.***
  150.  
  151. mynetworkstyle = host
  152.  
  153. ***note: above allows only local users on the postfix system itself to send mail.***
  154.  
  155. smtp_host_lookup = native (IMPORTANT!)
  156.  
  157. ***note: above disables the #$%& dns-resolver included in postfix and enables to use "/etc/
  158. resolv.conf" and "/etc/hosts".***
  159.  
  160. ignore_mx_lookup_error = yes (tor-resolve only returns A records .. or something)
  161. myhostname = 1234567890abcdef.onion (see file mentioned above: "/tor/hidden_service_postfix/hostname")
  162. mydomain = onion
  163.  
  164. Now check that there are not TWO directives with the same name, like this example:
  165. mynetworkstyle = host
  166. mynetworkstyle = subnet
  167.  
  168. One might override the other : (
  169.  
  170. Open firewall ports for "tcp:25" in "yast > security and users > firewall" in "Allowed services".
  171. Click on "Advanced".
  172.  
  173. Next start "postfix": "YAST > SYSTEM > System Services (Runlevel)". Select the "postfix" service
  174. and enable it.
  175.  
  176. ===
  177. postfix.system: LIGHTTPD and PHP5
  178. ====
  179. "YAST > Software > Software Manager" and search/install:
  180. +lighttpd
  181. +FastCGI
  182. +PHP5 / PHP5-fastcgi / PHP5-gettext / php5-iconv / PHP5-mbstring / PHP5-xml-reader / PHP5-xml-writer
  183. optional:
  184. +wget
  185. +mc
  186. +telnet
  187.  
  188. To enable PHP5 with lighttpd:
  189.  
  190. Edit file "/etc/lighttpd/modules.conf" and un-comment line:
  191. include "conf.d/fastcgi.conf"
  192.  
  193. Edit file "/etc/lighttpd/conf.d/fastcgi.conf":
  194. server.modules += ( "mod_fastcgi" )
  195. fastcgi.server => ( ".php" => ((
  196. "bin-path" => "/srv/www/cgi-bin/php",
  197. "socket" => "/srv/www/socket/sqmail.socket"
  198. )))
  199.  
  200. "/srv/www/socket/sqmail.socket" is a directory and owned by user "lighttpd".
  201. Create the "socket" directory and give ownership to user lighttpd and group lighttpd:
  202. >mkdir /srv/www/socket
  203. >mkdir /srv/www/socket/sqmail.socket
  204. >chown -R lighttpd:lighttpd /srv/www/socket
  205.  
  206. Some other directory for "php" and "squirrelmail to work":
  207. Create directory "/srv/www/php.cookies":
  208. >mkdir /srv/www/php.cookies
  209. >chown -R lighttpd:lighttpd /srv/www/php.cookies
  210.  
  211. Also adjust the listening port and ip.address in "/etc/lighttpd/lighttpd.conf" that
  212. "lighttpd" should use. In this example it is port:80 and ip.address: 192.168.0.25.
  213. Edit/add following lines:
  214. server.port = 80
  215. server.bind = "192.16.0.25"
  216.  
  217. Edit file "/etc/php5/fastcgi/php.ini", find / un-comment / change these three lines to read:
  218. cgi.fix_pathinfo = 1
  219. session.save_path = "/srv/www/php.cookies"
  220. sendmail_path = /usr/sbin/sendmail
  221.  
  222. ==========
  223. postfix.system: SQUIRRELMAIL (SQmail)
  224. ==========
  225. link: http://squirrelmail.org/
  226. squirrelmail PHP5 requirements: http://squirrelmail.org/docs/admin/admin-1.html#ss1.1
  227.  
  228. Fetch "Squirrelmail": http://squirrelmail.org/download.php (don't do this at home kids!):
  229. >wget http://prdownloads/sourceforge.net/squirrelmail/squirrelmail-webmail-1.4.22.tar.gz
  230.  
  231. use "mc" (MidnightCommander) or command-line to extract all to:
  232. /srv/www/htdocs
  233.  
  234. note: The location of the file "index.php" that comes from the unpacked
  235. "squirrelmail...tar.gz" should be here:
  236. /srv/www/htdocs/index.php
  237.  
  238. Do not make a sub-directory structure like this:
  239. /srv/www/htdocs/squirrelmail
  240.  
  241. Assuming "mc" was used to unpack the downloaded file "squirrelmail..tar.gz" to
  242. directory"/root/squirrelamil-webmail1.42" then you can do this:
  243. >cp -R /root/squirrelmail-webmail-1.42/* /srv/www/htdocs
  244.  
  245. Give ownership to user/group "lighttpd":
  246. >chown -R lighttpd:lighttpd /srv/www/htdocs
  247.  
  248. create a "data" directory and a "attach" directory for squirrelmail:
  249. >mkdir /srv/www/sqmail
  250. >mkdir /srv/www/sqmail/data
  251. >mkdir /srv/www/sqmail/attach
  252.  
  253. Give ownership to lighttpd, because it runs the php scripts of squirrelmail and wants
  254. to write to those directories:
  255. >chown -R lighttpd:lighttpd /srv/www/sqmail
  256.  
  257. To configure squirrelmail there are two options:
  258. 1) Run "conf.pl" in directory "/srv/www/htdocs/config":
  259. >/srv/www/htdocs/config/conf.pl
  260.  
  261. 2) Run "configure" in directory "/srv/www/htdocs":
  262. >/srv/www/htdocs/configure
  263.  
  264. Select "d" and chose/type:
  265. dovecot
  266. Go back (r-keyboard) to main squirrelmail configuration menu and select "4" for
  267. "General options" and enter the directories created above.
  268. For "data" directory:
  269. /srv/www/sqmail/data
  270. For "attach" directory:
  271. /srv/www/sqmail/attach
  272.  
  273. *IMPORTANT* To set the "sender domain", that is the stuff after the "@"sign, select "2" for
  274. "Server Settings" from the main menu and then enter the domain:
  275. 1234567890abcdef.onion (see file mentioned above: "/tor/hidden_service_postfix/hostname")
  276. This will report to the receiver where the omail came from so that the "reply"
  277. button works for them : )
  278.  
  279. We can start lighttpd now:
  280. Open firewall ports for "tcp:80" in "yast > security and users > firewall" in "Allowed services".
  281. Click on "Advanced".
  282.  
  283. Next start "lighttpd": "YAST > SYSTEM > System Services (Runlevel)". Select the "lighttpd"
  284. service and enable it.
  285.  
  286. To see what "Squirrelmail" thinks about the setup, (after starting "lighttpd") goto
  287. "http://192.168.0.25/src/configtest.php" with a browser.
  288.  
  289.  
  290.  
  291. =======
  292. postfix.system: DOVECOT
  293. =======
  294. link: http://www.dovecot.org/
  295. "YAST > Software > Software Management" search/install
  296. +dovecot21
  297. +dovecot21-backend-sqlite
  298. +SQLite
  299. +mailx
  300.  
  301. Edit file "/etc/dovecot/conf.d/10-mail.conf" and uncomment/add:
  302. mail_location = mbox:~/mail:INBOX=/var/mail/%u
  303.  
  304. Edit file "/etc/dovecot/users" and add users. The format is:
  305. username:password:user.id:group.id::/homedirectory
  306. link: http://wiki2.dovecot.org/BasicConfiguration
  307.  
  308. Example: There is a user "bob" with a dovecot-password "1234bob". His user.id
  309. is "1000" and group.id is "100". The "homedirectory" is "/home/bob".
  310. This would yield the following line in file "/etc/dovecot/users":
  311. bob:1234bob:1000:100::/home/bob
  312.  
  313. Note: "dovecot-password" indicates the password that bob wants to use to login
  314. to the dovecot-server. This is not(!) the system login password! Don't make it same : )
  315.  
  316. Note: The user.id and group.id can be checked with
  317. "YAST > Security and Users > User and Group Management" for each user.
  318.  
  319. Edit file "/etc/dovecot/conf.d/10-auth.conf". Then un-comment:
  320. disable_plaintext_auth = no
  321. auth_mechanisms = plain
  322. !include auth-passwdfile.conf.ext
  323.  
  324. And then edit file "/etc/dovecot/conf.d/auth_passwdfile.conf.ext" to something like this:
  325. passwd {
  326. driver = passwd_file
  327. args = scheme=plain username_format=%u /etc/dovecot/users
  328. }
  329. userdb {
  330. driver = passwd_file
  331. args = username_format=%u /etc/dovecot/users
  332. }
  333.  
  334. Next edit file "/etc/dovecot/conf.d/10-master.conf" and enable the IMAP service
  335. by uncommenting:
  336. default_internal_user = dovecot
  337. service imap_login {
  338. inet_listener imap {
  339. port = 143
  340. }
  341. inet_listener imaps {
  342. port = 993
  343. ssl = yes
  344. }
  345.  
  346. Note: Check that opening and closing brackets match up in numbers!
  347. The important part is to un-comment and thus enabling the directives.
  348.  
  349. At last edit "/etc/dovecot/dovecot.conf", uncomment lines:
  350. protocols = imap
  351. listen = 127.0.0.1
  352. base_dir = /var/run/dovecot/
  353. instance_name = dovecot
  354. login_greeting = Dovecot ready
  355.  
  356. The last thing to do now is start the "dovecot" service:
  357. "YAST > SYSTEM > System Services (Runlevel)". Select the "dovecot" service
  358. and enable it.
  359.  
  360. Note: A firewall port needs not be opened because "dovecot" is only listening
  361. on 127.0.0.1 -aka localhost.
  362.  
  363. The interface to send and receive omails is no available on the ip and port configured
  364. for lighttpd. In this howto it would be: http://192.168.0.25
  365.  
  366. [end]
  367.  
  368.  
  369. Q&A
  370.  
  371. How does it works?
  372. Squirrelmail is the "user interface". It is easy to use and works
  373. in a browsers. Just type "192.168.0.25" as a address into a browser (on the local LAN).
  374. The sending part goes via squirrelmail > php5.sendmail > postfix > (tor-resolve) > tor
  375. The receiving part goes via tor-hidden-service > postfix > dovecot > squirrelmail
  376.  
  377. How does postfix work with tor?
  378. postfix sees as receiver address (example) "cindy@123.onion". It contacts the configured DNS
  379. server. This is tor-resolver listening on port 5300.
  380. The tor-resolver sees that a *onion is requested and *cheats* by answering with a ip.address
  381. from the 10.192.0.0/10 range, example 10.192.0.1.
  382. postfix now contacts the server 10.192.0.1 via the default gateway it has configured, that
  383. is 192.168.0.2, which also happens to be the ip address of the tor running computer.
  384. Because the tor-running computer has a firewall/nat rule that says that all request coming
  385. to itself for 10.192.0.0/10 get redirected to 192.168.0.2:8081 it can now *intercept* the
  386. *onion request and transparently route the data ... simple : )
  387. If however postfix is receiving omails they will come from 192.168.0.2, that is through tor
  388. and tor is running on 192.168.0.2.
  389.  
  390. Can people using the tor network access my squirrelmail login page?
  391. Not with this how-to. Squirrelmail can only be accessed by computers that are on the 192.168.0.0/24
  392. network (local-lan). Even if tor is also on the local-lan there is no hidden-service defined
  393. for port 80, which is what lighttpd+squirrelmail is listening on.
  394. A hidden-service might be added to torrc configuration file for port 80 however.
  395. The only thing standing between you and people wanting to read your omail is then just
  396. the login password because they would see the squirrelmail login page.
  397. There is the possibility to have the squirrelmail login page avaialbe via a onion address that
  398. is different from the @onion omail address domain however: )
  399. A safer solution would be to setup a local VPN server. One would then tunnel/connect to this local
  400. VPN server into the local-lan and then access the only locally accessible squirrelmail instead.
  401.  
  402. Can people abuse my postfix as a spamming relay?
  403. Not with this how-to...i think.
  404. This setup only allows local users (with a real account) on the postfix.system to use postfix
  405. to SEND omail. The relevant entry in "main.cf" is "mynetworkstyle = host".
  406.  
  407. Why is DOVECOT using plain-text passwords?
  408. I'm a n00b : )
  409. DOVECOT is only listening on 127.0.0.1. If you don't share your computer with
  410. other users this shouldn't be a problem. Please feel free to make it "more" secure.
  411. "Quick-quick-make-it-easy-to-setup" is the motto here.
  412.  
  413. Can I make my postfix system even more secure?
  414. One could disable ARP on the postfix.system and statically map the MAC address and
  415. ip address of the tor running server in "/etc/ethers" (needs a entry on the tor running server also).
  416. this way the postfix computer only knows about one other computer on the local-lan: the tor running server.
  417. of course lighttpd+squirrelmail would only be accessible from a browser running on the postfix.system (unless
  418. also statically mapped via "/etc/ethers")
  419. It would need root to re-enable ARP broadcasts.
  420. A word of warning: If configuring a system via ssh DO NOT mess with ARP. you might lock yourself out!
  421.  
  422. ...
  423. sorry for typos : ) happy omailing! and thx to all the nice people who bring you
  424. free open-source GNU/Linux!
  425.  
  426. dopey1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement