dhondta / python-codext Goto Github PK
View Code? Open in Web Editor NEWPython codecs extension featuring CLI tools for encoding/decoding anything
License: GNU General Public License v3.0
Python codecs extension featuring CLI tools for encoding/decoding anything
License: GNU General Public License v3.0
Soo I was doing this ctf for which I thought I might need to perform some steg attacks. I ended-up installing StegoLSB which require tinyscript which require python-codext. BUT to my mistake I did this outside of a virtualenv.
Long story short, I eventually had to base64 decode a PDF, which despite my different attempts seemed empty. This was until I realised that calling base64 -d didn't call the beloved /usr/bin/base64 but the ~/.local/bin/base64 of python-codext.
Now the issue,
The script seems to be utf8 encoding the output (without reason) and this whether we redirect the output to a file or not.
As an example I get:
head -c 100 /tmp/a|base64 -d|hexdump -C
00000000 25 50 44 46 2d 31 2e 34 0a 31 20 30 20 6f 62 6a |%PDF-1.4.1 0 obj|
00000010 0a 3c 3c 0a 2f 54 69 74 6c 65 20 28 c3 be c3 bf |.<<./Title (....|
00000020 29 0a 2f 43 72 65 61 74 6f 72 20 28 c3 be c3 bf |)./Creator (....|
00000030 00 77 00 6b 00 68 00 74 00 6d 00 6c 00 74 00 6f |.w.k.h.t.m.l.t.o|
00000040 00 70 00 64 00 66 00 20 00 30 00 2e 00 31 00 0a |.p.d.f. .0...1..|
Instead of the expected:
base64.b64decode("JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7/KQovQ3JlYXRvciAo/v8AdwBrAGgAdABt")
b'%PDF-1.4\n1 0 obj\n<<\n/Title (\xfe\xff)\n/Creator (\xfe\xff\x00w\x00k\x00h\x00t\x00m'
# cat raw.txt
1Oh6axLwfecHErbVpRbtNj8t5JACsSQrofdnnMdQtBmoU8cQj6EyLcVRsQLz1MyWfXbqQDIc9wGyyBuH7uV95lBVpFGn3syGIw0IVLx8wJr4ABsIH9Q71hBH4AvIgljx7XnfjfmafahBNrPMDkK3dsJF0r41nzyMnOf7l36NcllAOgRLoB6Qh0APotZu6plYpkSiRCAkDKowOFm0mybKp336TAJe4JiDecD9hNbl5fBDLkGNYhmSkzOQzLBH1aPumW4o
# codext -i raw.txt decode base62
begin 666 <data>
M'XL( /H^)V("__-)SBB-<O7*+#;,K8PL\/ H\C#UR2LP= H)C0@-RZ\*"P@M
M\"T-\*@(#\]V\<A,*R^W\"@I,W9Q-,LU\8XR=$XM*TYR3PG,2G)+RO P#_'.
?"LRJS#)US0X(KPJH<$U.J@P(<TGR #3A(K<90
end
# codext -i raw.txt decode base62 | codext decode UU
Traceback (most recent call last):
File "/usr/lib/python3.8/encodings/uu_codec.py", line 58, in uu_decode
data = binascii.a2b_uu(s)
binascii.Error: Illegal char
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jeane/.local/bin/codext", line 8, in <module>
sys.exit(main())
File "/home/jeane/.local/lib/python3.8/site-packages/codext/__init__.py", line 124, in main
c = getattr(codecs, ["encode", "decode"][args.command == "decode"])(c, encoding, args.errors)
File "/home/jeane/.local/lib/python3.8/site-packages/codext/__common__.py", line 691, in decode
return lookup(encoding).decode(obj, errors)[0]
File "/usr/lib/python3.8/encodings/uu_codec.py", line 62, in uu_decode
data = binascii.a2b_uu(s[:nbytes])
binascii.Error: Illegal char
When I run it on linux and try to use "codext guess" or "codext rank" I get an error message saying:
# echo "3yZe7d" | codext rank
Traceback (most recent call last):
File "/usr/local/bin/codext", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/dist-packages/codext/__init__.py", line 184, in main
args.include, args.exclude = __format_list(args.include), __format_list(args.exclude, False)
AttributeError: 'Namespace' object has no attribute 'include'
Looks like there's a warning on the installation method via pip:
pip install codext
Collecting codext
Downloading codext-1.14.0.tar.gz (116 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 116.2/116.2 kB 1.7 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Requirement already satisfied: six in ./venv/lib/python3.10/site-packages (from codext) (1.16.0)
Collecting markdown2>=2.4.0
Downloading markdown2-2.4.6-py2.py3-none-any.whl (37 kB)
Installing collected packages: markdown2, codext
DEPRECATION: codext is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for codext ... done
Successfully installed codext-1.14.0 markdown2-2.4.6
Getting this error:
$ echo -en "test" | codext encode base64 gzip | codext guess
Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/bin/codext", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.11/site-packages/codext/__init__.py", line 254, in main
raise e
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.11/site-packages/codext/__init__.py", line 230, in main
s, lb = args.stop_function, args.lang_backend
^^^^^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'lang_backend'
Any ideas? I installed codext with pip. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.