Package: cryptatools-python3
Getting StartedThis is a cryptanalysis tool for exploit developers and ctf players.The name come from pwntools a similar tool to exploit memory corruption vulnerabilities. This software aims to work like pwntools but for cryptanalysis.Then this program include a library like pwnlib. And it will expose some command line tools. Like pwntools. This is a rewrite of the python version in rust in order to be able to be fast and portable and usable in the following various languages rust, python, ruby, javascript and kotlin together.PhilosophyThis tool aims to be professionnal. Not only a learning tool. It is for realistic exploitation and code breaking.You can "plug-in" your script to any protocol. Man in the midle as well as blockchain core as well as anything. Example:You are able to usepypcappython library to read packets and thendpktpython library to parse these and then you can usecryptatoolsto break encryption on these packets. This is why this library is avaible in many bindings such as python.You are able to userust-web3to parse a vulnerable cryptocurrency (shitcoin) blockchain hash tree to steal money using collision attack to forge a signature. Seethis reference.You can also work on programs obfuscated by encryption such as malware. In this case, you can decipher program data (eg: data contained in a dropper) as well as self-encrypyted code. In this way you can plug cryptatools with your favorite reverse engineering framwork. Eg:Install radare2. Then doradare2 -AA -i <yourscriptname>.rs <yourmalwaretoreverse>. If you work with python bindings,radare2 -AA -i <yourscriptname>.py <yourmalwaretoreverse>You can also work on extracted code from the malware:radare2<malwaretoreverse>;=>ssym.encrypted;pr12345>ciphertext.binWhere 12345 is the size of the encrypted function or code of the malware.The library is very very flexible.You can automatize any task. There is a command line interface.Installation1-Rust library installation.Installation ofcryptatools-corefor rust is same for any OS. InCargo.toml, just write:[dependencies]cryptatools-core={git="https://github.com/gogo2464/cryptatools-rs",package='cryptatools-core'}2-Python binding installation.To install the python Bindings you can use pip or build from source:2.1-Install python Bindings from pip:The namecryptatools-python3is the name of the package used to install cryptatools core python bindings. In order to install it, do:pip install cryptatools-python3It is updated of 1 subversion on each Pull Request and is then often update by the previous version.2.2-Build Python Bindings from sourcesIf you are on windows, with powershell do:python-mvenvmyenv.\myenv\Script\activatecargoinstalluniffi_bindgenpipinstallsetuptoolswheelgitclonehttps://github.com/gogo2464/cryptatools-rs;cdcryptatools-rspython.\cryptatools-core\setup.pybdist_wheel--verbose;$wheelFile=Get-ChildItem-Path.\dist\-Recurse-Include*;pip3install$wheelFile--force-reinstall;If you are on Linux, do:virtualenv-ppython3myenvsourcemyenv/bin/activate
cargoinstalluniffi_bindgen
pipinstallsetuptoolswheel
gitclonehttps://github.com/gogo2464/cryptatools-rs;cdcryptatools-rs
python3./cryptatools-core/setup.pybdist_wheel--verbose;pip3install./dist/*--force-reinstall;If you are on MacOs, do:virtualenv-ppython3myenvsourcemyenv/bin/activate
cargoinstalluniffi_bindgen
pipinstallsetuptoolswheel
gitclonehttps://github.com/gogo2464/cryptatools-rs;cdcryptatools-rs
python3./cryptatools-core/setup.pybdist_wheel--verbose;pip3install./dist/*--force-reinstall;3-cryptatools-cli the cli intrefaceCrytptatools command line interface is split into various program in order to follow the Linux philosophy. To install each one, do:gitclonehttps://github.com/gogo2464/cryptatools-rs/&&cargoinstall--path.\cryptatools-rs\cryptatools-cli\;(back to top)Usage</code></pre><p>crypytatools-clialsooffersawaytoscriptthelibraryincommandline.Donotforgettoinstalleachprogram.Seehowtoinstallthese<ahref="https://github.com/gogo2464/cryptatools#installation">here</a>formoreinformations.</p><p><code>cryptatools-cli-stats</code>doescryptanalysisstatisticalattacks.</p><prelang="shell"><code>cryptatools-cli-statsfrequency-analysis"123234"'{\"a\": [\"12\"],\"b\": [\"32\"],\"c\": [\"34\"]}'cryptatools-cli-encryptuses cryptography algorithm to encrypt data. Obviously you can use it for brute force cryptanalysis attack. But it is not the main philosophy ofcryptatools-rs.</code></pre>
<p>Formoreexamples,pleaserefertothe<ahref="https://github.com/gogo2464/cryptatools-rs/blob/master/TUTORIAL.md">Tutorial</a>ortothedocumentation<ahref="https://gogo2464.github.io/cryptatools-rs/cryptatools_core/">Documentation</a>.</p>
<palign="right">(<ahref="#top">backtotop</a>)</p>
<!--DOCUMENTATIONEXAMPLE-->
<h2>Documentation</h2>
<p><code>cryptatools-core</code>isawelldocumentedproject.</p>
<p>Inordertoseethecryptatoolsdocumentation.See:<ahref="https://gogo2464.github.io/cryptatools-rs/cryptatools_core/">theAPIdocumentation</a></p>
<palign="right">(<ahref="#top">backtotop</a>)</p>
<!--CONTRIBUTING-->
<h2>Contributing</h2>
<p>Contributionsarewhatmaketheopensourcecommunitysuchanamazingplacetolearn,inspire,andcreate.Anycontributionsyoumakeare<strong>greatlyappreciated</strong>.</p>
<p>Ifyouhaveasuggestionthatwouldmakethisbetter,pleaseforktherepoandcreateapullrequest.Youcanalsosimplyopenanissuewiththetag"enhancement".
Don'tforgettogivetheprojectastar!Thanksagain!</p>
<ol>
<li>Documentyourwork.See<ahref="https://github.com/gogo2464/cryptatools-rs#1-documentation">thehowtomakegooddocumentation</a>chapter.</li>
<li>Foreachmethodorobjectimplemented,donotforgettomaketestswithdoctest.See<ahref="https://github.com/gogo2464/cryptatools-rs#2-testing">here</a>.</li>
<li>CreatePythonbinding.See<ahref="https://github.com/gogo2464/cryptatools-rs#3-create-python-bindings">thislink</a>.</li>
<li>Benchmarkyourwork.See<ahref="https://github.com/gogo2464/cryptatools-rs#4-benchmarking">thislink</a>.</li>
<li>Createcliinterface.See<ahref="https://github.com/gogo2464/cryptatools-rs#5-create-cli">Thislink</a>.</li>
<li>OpenPR.</li>
</ol>
<!--DOCUMENTATIONEXAMPLE-->
<h2>1-Documentation</h2>
<p>Thedocumentationisgeneratedbydoctstringwithrustdoc.Toeditthedocumentation,gotothecodeandmodifythedoctstringafter<code>///</code>.</p>
<p>Then,inordertogeneratedocumentationfromrootfolderdo:</p>
<prelang="shell"><code>cargodoc--allFell free to view your own doc withcargo doc --open --allThis project usescargo doc.The documentation is self-generated on each pull request.To check if the cryptatools documentation has been updated after a merge request, see:the API documentation.(back to top)2-TestingIn order to run unit tests, you MUST be in the directory cryptatools-rs.
Run unit tests with doctests with the command:cargotest--allUnit test are made with doctests.(back to top)3-Create Python bindings.Cryptatools relies on uniffi to provide bindings to Python3. Ensure to provide Python3 bindings before making your Pull Request.To create Python Bindings, edit the filecryptatools-rs/src/cryptatools.udl. Edit it to add your newly created object as mentionned in the official uniffi documentation at this address:https://mozilla.github.io/uniffi-rs/udl_file_spec.html.Then do not forget to edit the filecryptatools-rs/cryptatools-core/src/lib.rsand just before the:uniffi_macros::include_scaffolding!("cryptatools");This step will generate a single python file that you could import directly. Sadly the good pratice you must do to import these is a bit more complicated.cryptatools-rs\cryptatools-core\setup.pyIn order to import your own crate, create the corresponding python file or folders undercryptatools-rs\cryptatools-core\bindings\python3\cryptatools-core\cryptanalysis\. Here you need to import the necessary objects from fromcryptatools_core.python3_bindings. Example, in the filecryptatools-rs\cryptatools-core\bindings\python3\cryptatools-core\cryptography\encryption\monoalphabetic_cipher\caesar_number.pywe just have written:from cryptatools_core.python3_bindings import CaesarNumberAlgorithm.Once this is done, fell free to write unit tests. At least one for each method implemented. The tests are writtenh in the filecryptatools-rs\cryptatools-core\binding-testing\testing.py.You are now free to test and compile your code withthe documentation at this link.(back to top)4-BenchmarkingSometimes, a function could sepnd too much time. In this case, you can debug your specific function from the template in the filebenches\cryptatools_benchmark\main.rs.Then test your function with:cargobenchIn the current state of cryptatools, it is not mandatory from a pull request to benchmark all the code. But could be considered as a good improvment.(back to top)5-Create cli.Each feature from cryptatools-core will be implemented to the cli in the foldercryptatools-cli. When you will have finish to implement your feature in incryptatools-core and when you have finish your feature in Python bindings, fell free to create the cli of your modifications.Then test it with:cargoinstall--path.\cryptatools-cli\;(back to top)LicenseThis software has a free software (libre) license. The license is GPL3.Fell free to ask me if you absolutely want to get a double licensing name. Then I could choose.(back to top)Contactgogo -gogo246475@gmail.comProject Link:https://github.com/gogo2464/cryptatools-rs(back to top)