ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#!/bin/bash
read -p "Choose a directory you wish to operate in: " var_1
mkdir -p $var_1/Hydra/.Despair0 && cd $var_1/Hydra/.Despair0
pwgen -1syN 63 160 | tee lock{1..1000} ### Create 1000 files and fill them with a bunch of text 1000 files so they all are a certain file size
for i in `ls -1`; do ### encrypt the 1000 files with random passswords that I do not know
password2=$(pwgen -1syN 1 10)
echo "$password2" | gpg --no-use-agent -c --cipher-algo twofish --passphrase "$password2" > $i.gpg
done
shopt -s extglob
shred -fuz !(*.gpg) ### delete all files without a gpg extension
until [ -f $var_3.gpg ]; do
read -sp "Choose a lock file to contain your secrets (lock1-1000): " var_3 #choosing a file to store my password but first it must be deleted and remade/re encrypted
echo ; done
shred -fuz $var_3.gpg && pwgen -1syN 63 160 > $var_3 ### delete a file from the 1000 files to remake it and specially encrypt it with a custom passphrase
while true; do ### confirm password
read -sp "Enter a passphrase to encrypt your secrets: " passvar_1
echo;read -sp "Confirm: " passvar_2
echo;[ "$passvar_1" = "$passvar_2" ] && break
echo "Please try again"
done
### this is the part whre I specially encrypt the file I deleted and remade
gpg --no-use-agent -c --cipher-algo twofish --passphrase "$passvar_1" $var_3 && shred -fuz $var_3
Last edited by justmy2cents; 08-22-2017 at 12:33 PM.
This is a snippet from a project im working on (im making GnuPG based password manager using Bash).. For some reason the file sizes dont match and im not understanding why. To elaborate, the problem I'm having is this line I think:
Code:
pwgen -1syN 63 160 | tee lock{1..1000} # Filler Text For The Decoy Lock Files In .Despair0
which is supposed to fill random text into the files so they are all a certain file size... This line below creates a file and that file is the file that im comparing to the rest of 999 files, and it for some reason doesn't match them in size. The below line is specifically for filling text into this special file (so it masquerades with their sizes), and as you can see in the script, both lines use pwgen -1syN 63 160, and are both encrypted with the same type of encryption so they should be the same file size.. All I did was delete the file and remake/re-encrypt it, so that I could set a custom passphrase on it (meaning not a randomly generated passphrase like the rest of them)
Why does this file (that I will use to store my passwords; which the above line creates, and the very last line encrypts) always ends up with a much larger file-szie than the rest of them...If you try this out yourself, then type ls -l you'll notice that the file the script has you choose (the "special" file aka my password file) ends up with a bigger file size than the rest of them.. If im making it sound complicated I apologize, it's not though it's simply that one file ends is bigger than the rest and im not sure why...
Last edited by justmy2cents; 08-20-2017 at 09:17 PM.
I am not familiar with pwgen, and as it appears to be window$ only I have no way to test it.
That said, it is not at all obvious that it should produce the same size file. The first question I would ask is whether the resulting file is valid - does it work as intended?
Thanks for your responses I found out what was wrong.. I was right I needed to change the line I suspected.. Not sure why, just trail and error.. Mainly I had to change echo "$password2" to echo "$password2:$filler1" Thanks anyways! Btw pwgen is not just for Windows, it works great on Linux, but I believe it was made by Microsoft.. Nevertheless Ill probably remove it as a dependency..
Code:
read -p "Choose a directory you wish to operate in: " var_1
mkdir -p $var_1/Hydra/.Despair0 && cd $var_1/Hydra/.Despair0
filler1=$(pwgen -1syN 63 160 | tee lock{1..1000}) ### Create 1000 files and fill them with a bunch of text 1000 files so they all are a certain file size
for i in `ls -1`; do ### encrypt the 1000 files with random passswords that I do not know
password2=$(pwgen -1syN 1 10)
echo "$password2:$filler1" | gpg --no-use-agent -c --cipher-algo twofish --passphrase "$password2" > $i.gpg
done
shopt -s extglob
shred -fuz !(*.gpg) ### delete all files without a gpg extension
until [ -f $var_3.gpg ]; do
read -sp "Choose a lock file to contain your secrets (lock1-1000): " var_3 #choosing a file to store my password but first it must be deleted and remade/re encrypted
echo ; done
shred -fuz $var_3.gpg ### delete a file from the 1000 files to remake it and specially encrypt it with a custom passphrase
while true; do ### confirm password
read -sp "Enter a passphrase to encrypt your secrets: " passvar_1
echo;read -sp "Confirm: " passvar_2
echo;[ "$passvar_1" = "$passvar_2" ] && break
echo "Please try again"
done
### this is the part whre I specially encrypt the file I deleted and remade
filler2=$(pwgen -1syN 63 160 > $var_3)
echo "$passvar_1:$filler2" | gpg --no-use-agent -c --cipher-algo twofish --passphrase "$passvar_1" $var_3 && shred -fuz $var_3
Last edited by justmy2cents; 08-22-2017 at 02:02 PM.
Theodore Yue Tak Ts'o (曹子德) (born 1968) is a software engineer mainly known for his contributions to the Linux kernel, in particular his contributions to file systems. He is the primary developer and maintainer of e2fsprogs, the userspace utilities for the ext2, ext3 and ext4 filesystems, and is a maintainer for the ext4 file system.
Unobtrusive, fully portable, runs on all 32-bit and 64-bit Windows versions
...and gives every indication in the page that it is pwgen. But I now see in the url it is really pwgen-win, advertising itself as PWGen. Intentionally confusing?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.