Fresh Grasshopper Seeking Knowledge on inputing awk scripts and working with them?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Fresh Grasshopper Seeking Knowledge on inputing awk scripts and working with them?
# 1  
Old 02-14-2019
Fresh Grasshopper Seeking Knowledge on inputing awk scripts and working with them?

Hey people people,


I am a new grasshopper willing to learn from the masters. I type a lot when I am nervous!



I have pulled tons of info off here in the last week concerning awk. I know nothing about awk, I mean nuthin. I have started work as the guy below the lowest man on the totumpole as a cyber security tech. I have a LOT to learn. I need to get a grip on awk. I decided after it was suggested to make me a cheatsheet with some commands. I found this forum and started working pulling what I saw and playing with it. Some of the things I need to be able to do concerns Nmap and wordlists.



I grabbed some info I tried but I don't even know how to use them in a terminal. If I could get someone to help me out some. I need to know how to take a text document, something like a short story that was copied and pasted into a text file and make it into a wordlist (one word per line) then remove the duplicates and be able to run it in any password cracker. I have to be able to do each one as a step.


Here is what my boss gave me. He copied a short story and put it in a text file. He has a test server that I must crack. He said not to bruteforce it (I wasn't ready for that) but he gave me a short story on a text file. He said the password for the server was in this story. I have to break the story down into a wordlist with no duplicates and get into the server where he has a file with my name on it and inside this file is an email address where I have to email it before a certain date and time.


I searched out a lot on here because I want to get it on my own. But I need help.



The last thing is, where is a site or a book title where I can read up on awk at it's most basic level. I would like to take what you help me with and break it down to get a much better understanding.

--- Post updated at 06:55 PM ---

I'm sorry. I read the response and thought it was something in general about posting code. So I overlooked it.


I have this
Code:
cat file1.txt file2.txt | sort | uniq > output.txt



Code:
awk '{ while(++i<=NF) printf (!a[$i]++) ? $i FS : ","; i=split("",a); print ""}' data

# 2  
Old 02-14-2019
Welcome to the forum,


and please please calm down. Careful and concise phrasing of your request, plus giving decent, detailed data samples, will increase your chances to get relevant answers to your question.


I, for instance, have no idea how you are to "crack the server" with a wordlist, not getting into or at least close to brute force. What in the wordlist will be the username? What the password? How will the server react after n failed login attempts - close the line? Slow down the line?


For a word list, you don't need awk at all. Try (with your above post in "textfile")

Code:
< textfile tr -s ' ,.' $'\n' | sort -u
a
able
about
address
.
.
.
working
would
you

Regarding your last question, these links might be useful:

https://www.unix.com/new-to-unix-whi...hould-i-read-/
https://www.unix.com/answers-to-freq...sked-questions

Last edited by RudiC; 02-14-2019 at 04:39 PM..
# 3  
Old 02-14-2019
I have the username. I am not sure if I follow. If your saying the code I posted will work then I am doing something wrong. I have used it many ways in a terminal but got no where.



Let me ask you what you put in. What is that?
# 4  
Old 02-14-2019
An always ready reference book comes with your system too. The man utility gives you access to the manual pages for the utilities and library routines available on your system. For example, to get details on how awk works, type the command:
Code:
man awk

into your shell. And, to get more information on how man works, try:
Code:
man man

# 5  
Old 02-14-2019
Been wondering how man works also. Thanks. Never used Linux till a couple months back.
# 6  
Old 02-14-2019
Code:
$ man tr

TR(1)                            User Commands                           TR(1)



NAME
       tr - translate or delete characters

SYNOPSIS
       tr [OPTION]... SET1 [SET2]
...
       -s, --squeeze-repeats
              replace each input sequence of  a  repeated  character  that  is
              listed in SET1 with a single occurrence of that character
...

So <inputfile tr -s ' ,.' $'\n' translates characters one-by-one as given by its arguments while reading from inputfile. -s tells tr to squeeze any number of spaces, commas, and periods in a row into one single newline character.

Then | feeds its input into sort -u, which sorts them alphabetically and excludes any duplicates. Not having been redirected anywhere else, it outputs to the terminal.
# 7  
Old 02-14-2019
Now how would I enter it into the terminal because I just tried and (Bash). I love this stuff but will really love it as I learn it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Scripts imported from UNIX to Linux are not working

Hi, Recently we migrated our app from Unix to Linux platform. All our shell scripts which use to work in Unix platform are not working in Linux now. below is such sample script. I tried removing trailing spaces, but no luck. dear experts kindly help.. #############BEGIN############### split... (7 Replies)
Discussion started by: laxman_bly
7 Replies

2. Shell Programming and Scripting

Inputing info from a CSV file and filling a template file

Hi, I have a .csv file that contains a variety of fields for 60 clients: USERNAME, PASSWORD, and COMMENTS. I have a template file which contains a great deal of data for each client and has the fields USERNAME, PASSWORD, and COMMENTS that has to be filled with the values of USERNAME,... (1 Reply)
Discussion started by: mojoman
1 Replies

3. UNIX for Advanced & Expert Users

Awk expressions working & not working

Hi, Putting across a few awk expressions. Apart from the last, all of them are working. echo a/b/c | awk -F'/b/c$' '{print $1}' a echo a/b/c++ | awk -F'/b/c++' '{print $1}' a echo a/b/c++ | awk -F'/b/c++$' '{print $1}' a/b/c++ Request thoughts on why putting a '$' post double ++... (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies

4. Shell Programming and Scripting

cron job is not working for two scripts

Hi Gurus, I have a test unix server in which currently some unix cronjob are running. I have written two script one is a shell script in which env variable are there (in that i am exporting those variables). I have also written a perl script . when i am running at the shell manually like... (5 Replies)
Discussion started by: sanjay.login
5 Replies

5. Shell Programming and Scripting

Linux - scripts not working in cron

hi all, i have scripts executable in manully, but not working in cron. any ideas? thanks a lot? * * * * * /home/dir/dir/file.sh #! /bin/sh alarmPath="/home/dir/monitoringAlarm" alarmDateTime="$(date +%Y%m%d) $(date +%H%M%S)" tomcatPID=`pidof /usr/local/jdk1.6.0_13/bin/java` echo "tomcat... (3 Replies)
Discussion started by: maxlee24
3 Replies

6. Red Hat

Linux - scripts not working in cron

hi all, i have scripts executable in manully, but not working in cron. any ideas? thanks a lot? * * * * * /home/dir/dir/file.sh #! /bin/sh alarmPath="/home/dir/monitoringAlarm" alarmDateTime="$(date +%Y%m%d) $(date +%H%M%S)" tomcatPID=`pidof /usr/local/jdk1.6.0_13/bin/java` echo "tomcat... (1 Reply)
Discussion started by: maxlee24
1 Replies

7. UNIX for Dummies Questions & Answers

alias not working in scripts

Hi All, PF below details, > cat run.sh #!/usr/bin/ksh alias ll="ls -l" > ./run.sh > ll ksh: ll: not found. Pls help on this? Thanks in Advance, Naga :cool: (2 Replies)
Discussion started by: Nagapandi
2 Replies

8. Shell Programming and Scripting

awk: seeking to bytes

can I seek to a particular byte in a file and replace it using awk? if so, how? (8 Replies)
Discussion started by: karyn1617
8 Replies

9. Shell Programming and Scripting

how to use ssh without inputing a password

hi, i am writing a script ssh root@192.168.0.200 ls -l , ssh always prompts me to enter a password, how to suppress it ,just like using rsh thanks (3 Replies)
Discussion started by: bugbugbug
3 Replies

10. Shell Programming and Scripting

Why passwd isnt working in shell scripts?

I had to write a script to change my login password, and the script wasnt working fine. When I searched through the previous postings in this forum, I got the solution (using 'expect' tool). But I would like to know why passwd command isnt working in scripts? (1 Reply)
Discussion started by: Deepa
1 Replies
Login or Register to Ask a Question