Showing posts with label Tor (anonymity network). Show all posts
Showing posts with label Tor (anonymity network). Show all posts

Thursday, October 27, 2016

macOS Sierra: Python Script Using Tor

Command:

$ /opt/local/bin/tor --hash-password "test"


Result:

16:3F088C0E24C9C9A460EAD2F1E2C15953A4FEECCB2FA2155C5458E778FC

Command:

$ cat /opt/local/etc/tor/torrc

## Configuration file for a typical Tor user
## Last updated 22 September 2015 for Tor 0.2.7.3-alpha.
## (may or may not work for much older or much newer versions of Tor.)
##
## Lines that begin with "## " try to explain what's going on. Lines
## that begin with just "#" are disabled commands: you can enable them
## by removing the "#" symbol.
##
## See 'man tor', or https://www.torproject.org/docs/tor-manual.html,
## for more options you can use in this file.
##
## Tor will look for this file in various places based on your platform:
## https://www.torproject.org/docs/faq#torrc

## Tor opens a SOCKS proxy on port 9050 by default -- even if you don't
## configure one below. Set "SOCKSPort 0" if you plan to run Tor only
## as a relay, and not make any local application connections yourself.
#SOCKSPort 9050 # Default: Bind to localhost:9050 for local connections.
#SOCKSPort 192.168.0.1:9100 # Bind to this address:port too.

## Entry policies to allow/deny SOCKS requests based on IP address.
## First entry that matches wins. If no SOCKSPolicy is set, we accept
## all (and only) requests that reach a SOCKSPort. Untrusted users who
## can access your SOCKSPort may be able to learn about the connections
## you make.
#SOCKSPolicy accept 192.168.0.0/16
#SOCKSPolicy accept6 FC00::/7
#SOCKSPolicy reject *

## Logs go to stdout at level "notice" unless redirected by something
## else, like one of the below lines. You can have as many Log lines as
## you want.
##
## We advise using "notice" in most cases, since anything more verbose
## may provide sensitive information to an attacker who obtains the logs.
##
## Send all messages of level 'notice' or higher to /opt/local/var/log/tor/notices.log
#Log notice file /opt/local/var/log/tor/notices.log
## Send every possible message to /opt/local/var/log/tor/debug.log
#Log debug file /opt/local/var/log/tor/debug.log
## Use the system log instead of Tor's logfiles
#Log notice syslog
## To send all messages to stderr:
#Log debug stderr

## Uncomment this to start the process in the background... or use
## --runasdaemon 1 on the command line. This is ignored on Windows;
## see the FAQ entry if you want Tor to run as an NT service.
#RunAsDaemon 1

## The directory for keeping all the keys/etc. By default, we store
## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
#DataDirectory /opt/local/var/lib/tor

## The port on which Tor will listen for local connections from Tor
## controller applications, as documented in control-spec.txt.
ControlPort 9051
## If you enable the controlport, be sure to enable one of these
## authentication methods, to prevent attackers from accessing it.
HashedControlPassword 16:3F088C0E24C9C9A460EAD2F1E2C15953A4FEECCB2FA2155C5458E778FC
CookieAuthentication 1

############### This section is just for location-hidden services ###

## Once you have configured a hidden service, you can look at the
## contents of the file ".../hidden_service/hostname" for the address
## to tell people.
##
## HiddenServicePort x y:z says to redirect requests on port x to the
## address y:z.

#HiddenServiceDir /opt/local/var/lib/tor/hidden_service/
#HiddenServicePort 80 127.0.0.1:80

#HiddenServiceDir /opt/local/var/lib/tor/other_hidden_service/
#HiddenServicePort 80 127.0.0.1:80
#HiddenServicePort 22 127.0.0.1:22

################ This section is just for relays #####################
#
## See https://www.torproject.org/docs/tor-doc-relay for details.

## Required: what port to advertise for incoming Tor connections.
#ORPort 9001
## If you want to listen on a port other than the one advertised in
## ORPort (e.g. to advertise 443 but bind to 9090), you can do it as
## follows.  You'll need to do ipchains or other port forwarding
## yourself to make this work.
#ORPort 443 NoListen
#ORPort 127.0.0.1:9090 NoAdvertise

## The IP address or full DNS name for incoming connections to your
## relay. Leave commented out and Tor will guess.
#Address noname.example.com

## If you have multiple network interfaces, you can specify one for
## outgoing traffic to use.
# OutboundBindAddress 10.0.0.5

## A handle for your relay, so people don't have to refer to it by key.
#Nickname ididnteditheconfig

## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must
## be at least 20 kilobytes per second.
## Note that units for these config options are bytes (per second), not
## bits (per second), and that prefixes are binary prefixes, i.e. 2^10,
## 2^20, etc.
#RelayBandwidthRate 100 KBytes  # Throttle traffic to 100KB/s (800Kbps)
#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)

## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes,
## not to their sum: setting "40 GB" may allow up to 80 GB total before
## hibernating.
##
## Set a maximum of 40 gigabytes each way per period.
#AccountingMax 40 GBytes
## Each period starts daily at midnight (AccountingMax is per day)
#AccountingStart day 00:00
## Each period starts on the 3rd of the month at 15:00 (AccountingMax
## is per month)
#AccountingStart month 3 15:00

## Administrative contact information for this relay or bridge. This line
## can be used to contact you if your relay or bridge is misconfigured or
## something else goes wrong. Note that we archive and publish all
## descriptors containing these lines and that Google indexes them, so
## spammers might also collect them. You may want to obscure the fact that
## it's an email address and/or generate a new address for this purpose.
#ContactInfo Random Person <nobody AT example dot com>
## You might also include your PGP or GPG fingerprint if you have one:
#ContactInfo 0xFFFFFFFF Random Person <nobody AT example dot com>

## Uncomment this to mirror directory information for others. Please do
## if you have enough bandwidth.
#DirPort 9030 # what port to advertise for directory connections
## If you want to listen on a port other than the one advertised in
## DirPort (e.g. to advertise 80 but bind to 9091), you can do it as
## follows.  below too. You'll need to do ipchains or other port
## forwarding yourself to make this work.
#DirPort 80 NoListen
#DirPort 127.0.0.1:9091 NoAdvertise
## Uncomment to return an arbitrary blob of html on your DirPort. Now you
## can explain what Tor is if anybody wonders why your IP address is
## contacting them. See contrib/tor-exit-notice.html in Tor's source
## distribution for a sample.
#DirPortFrontPage /opt/local/etc/tor/tor-exit-notice.html

## Uncomment this if you run more than one Tor relay, and add the identity
## key fingerprint of each Tor relay you control, even if they're on
## different networks. You declare it here so Tor clients can avoid
## using more than one of your relays in a single circuit. See
## https://www.torproject.org/docs/faq#MultipleRelays
## However, you should never include a bridge's fingerprint here, as it would
## break its concealability and potentially reveal its IP/TCP address.
#MyFamily $keyid,$keyid,...

## A comma-separated list of exit policies. They're considered first
## to last, and the first match wins.
##
## If you want to allow the same ports on IPv4 and IPv6, write your rules
## using accept/reject *. If you want to allow different ports on IPv4 and
## IPv6, write your IPv6 rules using accept6/reject6 *6, and your IPv4 rules
## using accept/reject *4.
##
## If you want to _replace_ the default exit policy, end this with either a
## reject *:* or an accept *:*. Otherwise, you're _augmenting_ (prepending to)
## the default exit policy. Leave commented to just use the default, which is
## described in the man page or at
## https://www.torproject.org/documentation.html
##
## Look at https://www.torproject.org/faq-abuse.html#TypicalAbuses
## for issues you might encounter if you use the default exit policy.
##
## If certain IPs and ports are blocked externally, e.g. by your firewall,
## you should update your exit policy to reflect this -- otherwise Tor
## users will be told that those destinations are down.
##
## For security, by default Tor rejects connections to private (local)
## networks, including to the configured primary public IPv4 and IPv6 addresses,
## and any public IPv4 and IPv6 addresses on any interface on the relay.
## See the man page entry for ExitPolicyRejectPrivate if you want to allow
## "exit enclaving".
##
#ExitPolicy accept *:6660-6667,reject *:* # allow irc ports on IPv4 and IPv6 but no more
#ExitPolicy accept *:119 # accept nntp ports on IPv4 and IPv6 as well as default exit policy
#ExitPolicy accept *4:119 # accept nntp ports on IPv4 only as well as default exit policy
#ExitPolicy accept6 *6:119 # accept nntp ports on IPv6 only as well as default exit policy
#ExitPolicy reject *:* # no exits allowed

## Bridge relays (or "bridges") are Tor relays that aren't listed in the
## main directory. Since there is no complete public list of them, even an
## ISP that filters connections to all the known Tor relays probably
## won't be able to block all the bridges. Also, websites won't treat you
## differently because they won't know you're running Tor. If you can
## be a real relay, please do; but if not, be a bridge!
#BridgeRelay 1
## By default, Tor will advertise your bridge to users through various
## mechanisms like https://bridges.torproject.org/. If you want to run
## a private bridge, for example because you'll give out your bridge
## address manually to your friends, uncomment this line:
#PublishServerDescriptor 0


Command:

$ /opt/local/bin/tor &


Result:

[1] 6463
Oct 27 15:00:19.225 [notice] Tor v0.2.8.9 running on Darwin with Libevent 2.0.22-stable, OpenSSL 1.0.2j and Zlib 1.2.8.
Oct 27 15:00:19.226 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Oct 27 15:00:19.226 [notice] Read configuration file "/opt/local/etc/tor/torrc".
Oct 27 15:00:19.229 [notice] Opening Socks listener on 127.0.0.1:9050
Oct 27 15:00:19.229 [notice] Opening Control listener on 127.0.0.1:9051
Oct 27 15:00:19.000 [notice] Parsing GEOIP IPv4 file /opt/local/share/tor/geoip.
Oct 27 15:00:19.000 [notice] Parsing GEOIP IPv6 file /opt/local/share/tor/geoip6.
Oct 27 15:00:19.000 [notice] Bootstrapped 0%: Starting
Oct 27 15:00:19.000 [notice] Bootstrapped 80%: Connecting to the Tor network
Oct 27 15:00:20.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
Oct 27 15:00:21.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
Oct 27 15:00:23.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.
Oct 27 15:00:23.000 [notice] Bootstrapped 100%: Done


Command:

$ cat tor.py


Result:

from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
    controller.authenticate()

    bytes_read = controller.get_info("traffic/read")
    bytes_written = controller.get_info("traffic/written")

    print("My Tor relay has read %s bytes and written %s." % (bytes_read, bytes_written))


Command:

$ python tor.py


Result:

Oct 27 15:02:42.000 [notice] New control connection opened from 127.0.0.1.
My Tor relay has read 687342 bytes and written 42071.

macOS Sierra: Installing Tor (anonymity network) Browser without GUI

Command:

$ brew install Caskroom/cask/macports


Result:

==> brew cask install Caskroom/cask/macports
==> Downloading https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.12-Sierra.pkg
######################################################################## 100.0%
==> Verifying checksum for Cask macports
==> Running installer for macports; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
==> installer: Package name is MacPorts
==> installer: Installing at base path /
==> installer: The install was successful.
🍺  macports was successfully installed!


Command:

$ sudo /opt/local/bin/port install tor


Result:

Warning: The Xcode Command Line Tools don't appear to be installed; most ports will likely fail to build.
Warning: Install them by running `xcode-select --install'.
--->  Computing dependencies for tor
--->  Dependencies to be installed: libevent openssl zlib
--->  Fetching archive for zlib
--->  Attempting to fetch zlib-1.2.8_0.darwin_16.x86_64.tbz2 from https://packages.macports.org/zlib
--->  Attempting to fetch zlib-1.2.8_0.darwin_16.x86_64.tbz2.rmd160 from https://packages.macports.org/zlib
--->  Installing zlib @1.2.8_0
--->  Activating zlib @1.2.8_0
--->  Cleaning zlib
--->  Fetching archive for openssl
--->  Attempting to fetch openssl-1.0.2j_0.darwin_16.x86_64.tbz2 from https://packages.macports.org/openssl
--->  Attempting to fetch openssl-1.0.2j_0.darwin_16.x86_64.tbz2.rmd160 from https://packages.macports.org/openssl
--->  Installing openssl @1.0.2j_0
--->  Activating openssl @1.0.2j_0
--->  Cleaning openssl
--->  Fetching archive for libevent
--->  Attempting to fetch libevent-2.0.22_3.darwin_16.x86_64.tbz2 from https://packages.macports.org/libevent
--->  Attempting to fetch libevent-2.0.22_3.darwin_16.x86_64.tbz2.rmd160 from https://packages.macports.org/libevent
--->  Installing libevent @2.0.22_3
--->  Activating libevent @2.0.22_3
--->  Cleaning libevent
--->  Fetching archive for tor
--->  Attempting to fetch tor-0.2.8.9_0.darwin_16.x86_64.tbz2 from https://packages.macports.org/tor
--->  Attempting to fetch tor-0.2.8.9_0.darwin_16.x86_64.tbz2.rmd160 from https://packages.macports.org/tor
--->  Installing tor @0.2.8.9_0
--->  Activating tor @0.2.8.9_0
--->  Cleaning tor
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.


Command:

$ xcode-select --install


Result:

xcode-select: note: install requested for command line developer tools

macOS Sierra: Tor (anonymity network): Installing ARM (The anonymizing relay monitor): Incomplete

Command:

$ git clone https://git.torproject.org/nyx.git


Result:

Cloning into 'nyx'...
remote: Counting objects: 11674, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 11674 (delta 42), reused 0 (delta 0)
Receiving objects: 100% (11674/11674), 2.71 MiB | 446.00 KiB/s, done.
Resolving deltas: 100% (9078/9078), done.


Command:

$ cd nyx
$ python setup.py


Result (Error):

Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    import nyx
  File "/Users/USERNAME/nyx/nyx/__init__.py", line 41, in <module>
    import stem
ImportError: No module named stem


Command:

$ sudo pip install stem
Password:


Result:

The directory '/Users/USERNAME/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/USERNAME/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting stem
  Downloading stem-1.4.0.tar.bz2 (1.6MB)
    100% |████████████████████████████████| 1.6MB 718kB/s
Installing collected packages: stem
  Running setup.py install for stem ... done
Successfully installed stem-1.4.0


Command:

$ python setup.py


Result (Error):

Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    import nyx
  File "/Users/USERNAME/nyx/nyx/__init__.py", line 521, in <module>
    import nyx.panel.config
  File "/Users/USERNAME/nyx/nyx/panel/config.py", line 17, in <module>
    import stem.manual
ImportError: No module named manual


Command:

$ python


Result:

Python 2.7.12 (default, Oct 19 2016, 01:11:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.


Command:

>>> import sys
>>> sys.path


Result:

['', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/usr/local/Cellar/matplotlib/1.5.1/libexec/lib/python2.7/site-packages', '/usr/local/Cellar/numpy/1.11.2/libexec/nose/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg', '/Library/Python/2.7/site-packages']


Command:

>>> quit()
$ ls -al /usr/local/lib/python2.7/site-packages/stem/


Result (Missing stem.manual):

total 1136
drwxr-xr-x  22 root  wheel     748 Oct 27 12:06 .
drwxr-xr-x  43 USERNAME  wheel    1462 Oct 27 12:06 ..
-rw-r--r--   1 root  wheel   25346 May 14  2015 __init__.py
-rw-r--r--   1 root  wheel   27294 Oct 27 12:06 __init__.pyc
-rw-r--r--   1 root  wheel   48656 May 14  2015 connection.py
-rw-r--r--   1 root  wheel   45507 Oct 27 12:06 connection.pyc
-rw-r--r--   1 root  wheel  128760 May 14  2015 control.py
-rw-r--r--   1 root  wheel  118390 Oct 27 12:06 control.pyc
drwxr-xr-x  24 root  wheel     816 Oct 27 12:06 descriptor
-rw-r--r--   1 root  wheel   34569 May 14  2015 exit_policy.py
-rw-r--r--   1 root  wheel   31176 Oct 27 12:06 exit_policy.pyc
drwxr-xr-x  13 root  wheel     442 Oct 27 12:06 interpreter
-rw-r--r--   1 root  wheel    3430 May 14  2015 prereq.py
-rw-r--r--   1 root  wheel    4029 Oct 27 12:06 prereq.pyc
-rw-r--r--   1 root  wheel    8996 May 14  2015 process.py
-rw-r--r--   1 root  wheel    7768 Oct 27 12:06 process.pyc
drwxr-xr-x  18 root  wheel     612 Oct 27 12:06 response
-rw-r--r--   1 root  wheel   21337 May 14  2015 socket.py
-rw-r--r--   1 root  wheel   19283 Oct 27 12:06 socket.pyc
drwxr-xr-x  29 root  wheel     986 Oct 27 12:06 util
-rw-r--r--   1 root  wheel   12810 May 14  2015 version.py
-rw-r--r--   1 root  wheel   14866 Oct 27 12:06 version.pyc

Monday, October 3, 2016

Python: ONIOFF - Onion URL Inspector: Installing and Running

Command:

$ git clone https://github.com/k4m4/onioff


Result:

Cloning into 'onioff'...
remote: Counting objects: 57, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 57 (delta 30), reused 52 (delta 25), pack-reused 0
Unpacking objects: 100% (57/57), done.


Command:

$ cd onioff
$ ls


Result:

CHANGES.rst README.rst onioff.py requirements.txt
LICENSE VERSION reports termcolor.py


Command:

$ cat requirements.txt


Result:

requests
pysocks


Command:

$ pip install -r requirements.txt


Result:

Collecting requests (from -r requirements.txt (line 1))
  Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
    100% |████████████████████████████████| 522kB 1.5MB/s
Collecting pysocks (from -r requirements.txt (line 2))
  Downloading PySocks-1.5.7.tar.gz
Collecting beautifulsoup4 (from -r requirements.txt (line 3))
  Downloading beautifulsoup4-4.5.1-py2-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 4.1MB/s
Building wheels for collected packages: pysocks
  Running setup.py bdist_wheel for pysocks ... done
  Stored in directory: /Users/USERNAME/Library/Caches/pip/wheels/cf/81/67/77884514e566867d5223e5530e27ce9b9433b78c766a400313
Successfully built pysocks
Installing collected packages: requests, pysocks, beautifulsoup4
Successfully installed beautifulsoup4-4.5.1 pysocks-1.5.7 requests-2.11.1


Command:

$ python onioff.py -h


Result:

 ██████╗ ███╗   ██╗██╗ ██████╗ ███████╗███████╗
██╔═══██╗████╗  ██║██║██╔═══██╗██╔════╝██╔════╝
██║   ██║██╔██╗ ██║██║██║   ██║█████╗  █████╗
██║   ██║██║╚██╗██║██║██║   ██║██╔══╝  ██╔══╝
╚██████╔╝██║ ╚████║██║╚██████╔╝██║     ██║
 ╚═════╝ ╚═╝  ╚═══╝╚═╝ ╚═════╝ ╚═╝     ╚═╝ v0.1

          Onion URL Inspector (ONIOFF)        
  Made With <3 by: Nikolaos Kamarinakis (k4m4)
                  Version: 0.1                
Usage: python onioff.py {onion} [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -f FILE, --file=FILE  onion filename
  -o OUTPUT_FILE, --output=OUTPUT_FILE
                        output filename

Examples:
  python onioff.py http://xmh57jrzrnw6insl.onion/
  python onioff.py -f ~/onions.txt -o ~/report.txt
  python onioff.py https://facebookcorewwwi.onion/ -o ~/report.txt


Command:

$ python onioff.py -f ~/onions.txt -o ~/report.txt


Result:

 ██████╗ ███╗   ██╗██╗ ██████╗ ███████╗███████╗
██╔═══██╗████╗  ██║██║██╔═══██╗██╔════╝██╔════╝
██║   ██║██╔██╗ ██║██║██║   ██║█████╗  █████╗
██║   ██║██║╚██╗██║██║██║   ██║██╔══╝  ██╔══╝
╚██████╔╝██║ ╚████║██║╚██████╔╝██║     ██║
 ╚═════╝ ╚═╝  ╚═══╝╚═╝ ╚═════╝ ╚═╝     ╚═╝ v0.1

          Onion URL Inspector (ONIOFF)        
  Made With <3 by: Nikolaos Kamarinakis (k4m4)
                  Version: 0.1                

[+] Commencing Onion Inspection
[-] Tor Offline --> Please Make Sure Tor Is Running
[-] System Exit