LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-17-2015, 04:48 AM   #1
zardoz1971
LQ Newbie
 
Registered: Aug 2015
Posts: 2

Rep: Reputation: Disabled
Bash script - John the Ripper


Hello. I'm trying to make process of restoring John the Ripper's .rec files. Instead of typing whole command:

john --restore=record | aircrack-ng -w - -b 00:11:22:33:44:55 record.cap

I tried with bash script:

#!/bin/bash

sudo john --restore=record | aircrack-ng -w - -b 00:11:22:33:44:55


It works as it is but...

John has a feature of showing where process of aircracking is when you press any button. Also, when you press q button it saves where it stopped and quits. None of that works when started with script. Only thing I can press and get response is Ctrl + C to quit the process.

Question is can I start process using bash script so it starts exactly the same way as it would if it was started by command only, so the process would react to key presses?

TIA
 
Old 08-17-2015, 05:17 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,217

Rep: Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686
sudo valid only before pipe, so aircrack was executed as current user.
You ought to try:
sudo your_bash_script
and bash script contains:
john --restore=record | aircrack-ng -w - -b 00:11:22:33:44:55 record.cap

Probably that helps
 
Old 08-17-2015, 05:51 AM   #3
zardoz1971
LQ Newbie
 
Registered: Aug 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
It doesn't help. With or without sudo in script it's the same problem.

As I said. Script runs but John the Ripper's "hotkeys" are disabled.
 
Old 08-17-2015, 10:56 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by zardoz1971 View Post
It doesn't help. With or without sudo in script it's the same problem.

As I said. Script runs but John the Ripper's "hotkeys" are disabled.
You might check the documentation.

It is possible that the program opens /dev/tty directly to implement that, and sudo by default disables terminal access.
 
Old 08-02-2017, 03:08 PM   #5
TimewarpUK
Member
 
Registered: Dec 2014
Posts: 33

Rep: Reputation: Disabled
Quote:
Originally Posted by zardoz1971 View Post
Hello. I'm trying to make process of restoring John the Ripper's .rec files. Instead of typing whole command:

john --restore=record | aircrack-ng -w - -b 00:11:22:33:44:55 record.cap

I tried with bash script:

#!/bin/bash

sudo john --restore=record | aircrack-ng -w - -b 00:11:22:33:44:55


It works as it is but...

John has a feature of showing where process of aircracking is when you press any button. Also, when you press q button it saves where it stopped and quits. None of that works when started with script. Only thing I can press and get response is Ctrl + C to quit the process.

Question is can I start process using bash script so it starts exactly the same way as it would if it was started by command only, so the process would react to key presses?

TIA
Did you ever solve this? My script to call John with different wordlists does not allow the hotkeys to work either, and I'm not using sudo.
 
Old 08-02-2017, 05:57 PM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
When you run john from the command line the virtual terminal is the shell. But each script has its own shell. Thus, hot keys in the virtual terminal do not affect john called from the script. I don't know of any easy way around this.
 
Old 08-04-2017, 10:53 AM   #7
TimewarpUK
Member
 
Registered: Dec 2014
Posts: 33

Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
When you run john from the command line the virtual terminal is the shell. But each script has its own shell. Thus, hot keys in the virtual terminal do not affect john called from the script. I don't know of any easy way around this.
Interesting. How do other binaries accept user input when ran inside a script? e.g. it works with nmap
 
Old 08-05-2017, 09:04 PM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I believe it's the way the key capture is implemented. But I'm not an expert.
 
Old 08-06-2017, 07:00 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by TimewarpUK View Post
Interesting. How do other binaries accept user input when ran inside a script? e.g. it works with nmap
Nmap just reads stdin/stdout. sudo does not, its use for password authentication opens /dev/tty to bypass possible spoofs.

Your use of piping the output john to aircrack-ng doesn't really make sense, no input to aircrack will be accepted.

Note: using the pipe separates the sudo command from aircrack - so aircrack will only run under your original account, not as root (or what is specified for john in the sudo configuration file).
 
Old 08-07-2017, 10:49 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,217

Rep: Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686Reputation: 7686
to jpollard: TimewarpUK reopened an old, abandoned thread.
Quote:
Originally Posted by TimewarpUK View Post
Interesting. How do other binaries accept user input when ran inside a script? e.g. it works with nmap
Usually binaries inherit stdin/stdout/stderr from their parent processes, so for example nmap will read stdin as long as it runs and bash will read it again when nmap completed (this is not the whole story, but in short you can imagine something like this).

As it was explained sudo does not rely on it, but uses the terminal (/dev/tty) directly which will not work if actually there was no terminal available.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Using John the Ripper kaplan71 Linux - Software 1 09-23-2009 06:44 AM
John The Ripper infinity0022 Linux - Security 1 02-24-2008 01:23 AM
John the Ripper help BigChuckP Linux - Security 3 02-10-2006 10:44 AM
John the Ripper Baix Linux - Software 2 02-21-2005 12:05 PM
John the ripper Ephracis Linux - Software 2 12-01-2004 01:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:27 AM.

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