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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printf or any other method to put long string of spec characters - passing passwords
# 1  
Old 11-14-2017
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 07:10 AM.. Reason: CODE tags and spelling corrections
# 2  
Old 11-14-2017
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 03:45 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 11-15-2017
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to put a 80 character limit on a long topic line in markdown?

I have a topic line in markdown that spans more than 80 characters that i need to add a line break. Markdown is simply treating the line break as a brand new line instead of continuing as a topic line. Eg: # This is a very long line Markdown interprets it as This is a very long line (4 Replies)
Discussion started by: dragonpoint
4 Replies

2. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

3. Shell Programming and Scripting

Align with printf or other method

below line is one by one print audio_play PASS boot_check FAIL ethernet_change_mac NIC_82574L PASS gps_ublox_neo FAIL storage_bonnie USB2 PASS storage_copy_big_file USB2 PASS I would like below format ... (7 Replies)
Discussion started by: yanglei_fage
7 Replies

4. Programming

Passing printf formatting parameters as variables

Hi, I haven't programed in C in a few years. I have been doing a lot of shell scripting, I.E. not really programming anything heavy. :o That said, I have a script that gives hourly usage statistics for our email server. It runs w-a-y to slow as a script for my impatience, and needs to... (7 Replies)
Discussion started by: mph
7 Replies

5. Shell Programming and Scripting

Reading a string and passing passing arguments to a while loop

I have an for loop that reads the following file cat param.cfg val1:env1:opt1 val2:env2:opt2 val3:env3:opt3 val4:env4:opt4 . . The for loop extracts the each line of the file so that at any one point, the value of i is val1:env1:opt1 etc... I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies

6. Shell Programming and Scripting

Need help with spec. characters.

Hi., I need transfer as parameter into shell script some spec. characters, for example " or ' or & or \ at the end of second parameter. (this parameter used as changed password). How I can transfer it into shell script. Thanks Staas,. (5 Replies)
Discussion started by: beckss
5 Replies

7. Shell Programming and Scripting

SSH - Passing Unix login passwords through shell scripts

Hi All , I need to call a script runscript_B.sh on server A, the runscript_B.sh script locating in server B. The runscript_B.sh in calls another script runscript_A on server A itself. it seend, i need to be connect from Server A to Server B using ssh. I have tryed like this in... (3 Replies)
Discussion started by: koti_rama
3 Replies

8. Programming

How i can read a long integer from standar input and a string with as many characters as specified..

how i can read a long integer from standar input and a string with as many characters as specified in the number? i thing that i must use the read command ofcourse.... (6 Replies)
Discussion started by: aintour
6 Replies
Login or Register to Ask a Question