diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..600d2d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..59d164f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 RQ-21-Engineer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9a53d30 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +build : + + mkdir bin + g++ pswdgn.cpp -o pswdgn + mv pswdgn.exe ./bin + +run : + + C:\Users\kiwog\Documents\projects\"hacking projects"\pswdgn\bin\pswdgn.exe -l 256 --all > password.txt + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..71815ab --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# pswdgn + + **_pswdgn_** is a tool for generate password, public / private key, and other credentials. + +
+ +# USAGE + +## Installation + +``` +using g++ : + $ g++ pswdgn.cpp -o pswdgn + +using gcc : + $ gcc pswdgn.cpp -o pswdgn -lstdc++ + +using clang : + $ clang pswdgn.cpp -o pswdgn -lstdc++ + +using clang++ : + $ clang++ pswdgn.cpp -o pswdgn +``` + +## how to use + +``` +docs : + pswdgn [ -L | --length ] [NUMBER] [ -ON | --only-number ] + +example : + $ pswdgn -l 256 --all > password.txt +``` \ No newline at end of file diff --git a/bin/pswdgn.exe b/bin/pswdgn.exe new file mode 100644 index 0000000..c2dd34d Binary files /dev/null and b/bin/pswdgn.exe differ diff --git a/example/expectsh.sh b/example/expectsh.sh new file mode 100644 index 0000000..e0bba44 --- /dev/null +++ b/example/expectsh.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +pswdgn -l 256 --all > password.txt + +# read https://www.howtogeek.com/devops/automate-inputs-to-linux-scripts-with-the-expect-command/ +cat << 'EOF' > expectsh.exp +#!/usr/bin/expect -f + +set timeout -1 + +spawn ./register + +expect "new username : r" +send -- "rootr" + +expect "new password : r" +send -- "$(cat password.txt)" + +expect eof +EOF + +: ' +Which user? +u user/owner +g group +o other +a all +What to do? ++ add this permission +- remove this permission += set exactly this permission +Which permissions? +r read +w write +x execute +' +chmod ugo+x expectsh.exp + + +./expectsh.exp + + + + + + + diff --git a/example/freepascal.pas b/example/freepascal.pas new file mode 100644 index 0000000..77eafc3 --- /dev/null +++ b/example/freepascal.pas @@ -0,0 +1,19 @@ +program powerWIN; + +uses SysUtils, Process; + +begin + ExecuteProcess('cmd','/c pswdgn -l 256 --all > password.txt'); +end. + + + + + + + + + + + + diff --git a/include/generator.h b/include/generator.h new file mode 100644 index 0000000..3731bac --- /dev/null +++ b/include/generator.h @@ -0,0 +1,59 @@ +#include +#include +#include +#include +#include + + + +class Generator { + + public : + void key (int lengthKey, bool numberOnlyOption) { + + std::string result = ""; + + std::string numberCharacters = "1234567890"; + std::string lowerCharacters = "abcdefghijklmnopqrstuvwxyz"; + std::string upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + std::string allCharacters = ( + + lowerCharacters + + numberCharacters + + upperCharacters + ); + + srand ( + time(0) + ); + + if ( numberOnlyOption ) { + + for (int i = 0; i < lengthKey; i ++) { + + result += numberCharacters [ + + rand() % numberCharacters.length() + ]; + + } + + } else { + + for ( int i = 0; i < lengthKey; i ++) { + + result += allCharacters [ + + rand() % allCharacters.length() + ]; + + } + } + + std::cout << result << std::endl; + } + +}; + + + diff --git a/pswdgn.cpp b/pswdgn.cpp new file mode 100644 index 0000000..a0b829d --- /dev/null +++ b/pswdgn.cpp @@ -0,0 +1,39 @@ +#include "include/generator.h" + + +int main (int argc, char** argv) { + + Generator gen; + + if( (strcmp(argv[1], "-l") == 0) || (strcmp(argv[1], "--length") == 0) ) { + + + if( (strcmp(argv[3], "-on") == 0) || (strcmp(argv[3], "--only-number") == 0) ) { + + gen.key( + + std::atoi(argv[2]), true + ); + + + }else if( (strcmp(argv[3], "-a") == 0) || (strcmp(argv[3], "--all") == 0) ){ + + gen.key( + + std::atoi(argv[2]), false + ); + + } + + + } else { + + std::cout << "pswdgn [ -L | --length ] [NUMBER] [ -ON | --only-number ]" << std::endl; + } + + + return 0; + +} + +