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


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-14-2017   -   Original Discussion by elxa1
elxa1's Unix or Linux Image
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; 11-15-2017 at 06:10 AM.. Reason: CODE tags and spelling corrections
Sponsored Links
    #2  
Old Unix and Linux 11-14-2017   -   Original Discussion by elxa1
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 23 May 2018, 2:52 PM EDT
Location: Amsterdam
Posts: 11,807
Thanks: 543
Thanked 3,441 Times in 3,034 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; 11-14-2017 at 02:45 PM..
The Following User Says Thank You to Scrutinizer For This Useful Post:
MadeInGermany (11-14-2017)
Sponsored Links
    #3  
Old Unix and Linux 11-15-2017   -   Original Discussion by elxa1
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is online now Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 24 May 2018, 2:17 AM EDT
Location: Simplicity
Posts: 4,084
Thanks: 351
Thanked 1,379 Times in 1,243 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
Closed

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 06:44 PM
Align with printf or other method yanglei_fage Shell Programming and Scripting 7 08-27-2014 04:11 PM
Need help with spec. characters. beckss Shell Programming and Scripting 5 06-21-2011 02: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 02:19 PM



All times are GMT -4. The time now is 02:21 AM.