Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Printf or any other method to put long string of spec characters - passing passwords

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 4 Days Ago   -   Original Discussion by elxa1
elxa1 elxa1 is offline
Registered User
 
Join Date: Aug 2017
Last Activity: 14 November 2017, 2:18 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Printf or any other method to put long string of spec characters - passing passwords

Hello,

I am looking for a method to use in my bash script which allows me to use long strings with all special characters.

I have found that printf method could be helpful for me but unfortunately, when I trying

Code:
root@machine:~# tevar=`printf "%s%c" "'``fF/0,g_V/Y)>^.(a0(,%<A.`8N:q*Rd|lCy0t9N'FDPs|S,$2(^$/*>5Ush*w87L#m@t~:[Ple+=Od633Z3m3xGV.zX+a-N%x1K=J7gOO=?1c$HZU78iVtJG1N[s@-eH#DwH]V5l}??XWI.YJ;4%:LmAEML9%4jm'Y6GXTc{DT7Iia$!+/[x.),b]5`iO3E,-+,44+9Fke45Z=m^ba.EP^)+GqZ.uQNF*sU9'Kxq6i19+ie*6rZjjCC.2`rSYVqlmHlHqeFBCapXXSxXROXUrljMWGsicEdCdPJuvbXnPXlENaBzpMBnRgtGsFtTYbHsyilugLrTSTMvGDGqSIhXhJISqnIuBwxfqr`'" ; echo $tevar
-bash: błąd składni przy nieoczekiwanym znaczniku `)'

I am getting error

Code:
-bash: błąd składni przy nieoczekiwanym znaczniku `)'

What is important - I need to pass different length strings, I don't know the length, and the positions of special characters.
This is a password from my password list and I need find working pass to archive.

What can I do to pass very long stream with any special character as a string and put it as variable in bash script?

Or - maybe I can make it outside the bash ? I am using 7 zip command line tool where I need to put the password as parameter like

7z t -pP@55w0rd!

where P@55w0rd! is my password.

What was my fault before (long time ago)- I have had used almost 5000 characters in passwords. I have lot of possible passes in my dictionary, and I am sure, that one of them will be correct.

Last edited by rbatte1; 3 Days Ago at 07:10 AM.. Reason: CODE tags and spelling corrections
Sponsored Links
    #2  
Old Unix and Linux 4 Days Ago   -   Original Discussion by elxa1
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 18 November 2017, 5:35 PM EST
Location: Amsterdam
Posts: 11,618
Thanks: 516
Thanked 3,380 Times in 2,979 Posts
Try:

Code:
var=$( 
cat << "EOF"
'``fF/0,g_V/Y)>^.(a0(,%<A.`8N:q*Rd|lCy0t9N'FDPs|S,$2(^$/*>5Ush*w87L#m@t~:[Ple+=Od633Z3m3xGV.zX+a-N%x1K=J7gOO=?1c$HZU78iVtJG1N[s@-eH#DwH]V5l}??XWI.YJ;4%:LmAEML9%4jm'Y6GXTc{DT7Iia$!+/[x.),b]5`iO3E,-+,44+9Fke45Z=m^ba.EP^)+GqZ.uQNF*sU9'Kxq6i19+ie*6rZjjCC.2`rSYVqlmHlHqeFBCapXXSxXROXUrljMWGsicEdCdPJuvbXnPXlENaBzpMBnRgtGsFtTYbHsyilugLrTSTMvGDGqSIhXhJISqnIuBwxfqr`'
EOF
)
printf "%s\n" "$var"

--
To read a text that you do not want prompted and put it in variable passw , you can use:

Code:
read -s passw


Last edited by Scrutinizer; 4 Days Ago at 03:45 PM..
The Following User Says Thank You to Scrutinizer For This Useful Post:
MadeInGermany (4 Days Ago)
Sponsored Links
    #3  
Old Unix and Linux 3 Days Ago   -   Original Discussion by elxa1
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 18 November 2017, 2:39 PM EST
Location: Simplicity
Posts: 3,822
Thanks: 318
Thanked 1,281 Times in 1,159 Posts
The "here document" is the correct method of storing a password in the script.
--
If you have a pwlist with one password per line then you can do

Code:
while IFS= read -r pw
do
  printf "%s\n" "$pw"
  echo 7z t -p"$pw"
done < pwlist

Remove the echo to run the 7z command.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to avoid "Too many arguments" error, when passing a long String literal as input to a command? cool.aquarian Shell Programming and Scripting 4 03-06-2015 07:44 PM
Align with printf or other method yanglei_fage Shell Programming and Scripting 7 08-27-2014 05:11 PM
Need help with spec. characters. beckss Shell Programming and Scripting 5 06-21-2011 03:12 AM
How i can read a long integer from standar input and a string with as many characters as specified.. aintour Programming 6 10-15-2009 03:19 PM



All times are GMT -4. The time now is 07:03 PM.