LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 03: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, 04:17 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,604

Rep: Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604Reputation: 5604
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, 04: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, 09:56 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,910

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
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, 02: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, 04:57 PM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
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, 09: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, 08:04 PM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

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

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
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, 09:49 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,604

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

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

All times are GMT -5. The time now is 02:54 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