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

cat file1.txt file2.txt | sort | uniq > output.txt
awk '{ while(++i<=NF) printf (!a[$i]++) ? $i FS : ","; i=split("",a); print ""}' data

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")

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

Regarding your last question, these links might be useful:

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?

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:

man awk

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

man man

Been wondering how man works also. Thanks. Never used Linux till a couple months back.

$ 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.

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.

You must receive your password at the output

awk 'BEGIN {RS="[[:space:]]+"; ORS="\n"}
/[[:punct:]]/ && /[[:digit:]]/ && /[[:lower:]]/ && /[[:upper:]]/ && /_/ {print}' story.txt

Without applying brute force, i.e. bruteforce

--- Post updated at 20:44 ---

This means that the password was created by a knowledgeable person in accordance with all security rules. And since the password is in the list of words in the story, we can find it by the presence of certain characters - "punctuation, upper and lower case characters, numbers and underscores"

Wouldn't it have been nice to mention that in your introductory post? Plus the tool / command you use to connect to the server.

Nor do I.

I'm sorry, I never said that. I didn't comment at all on your code as it was posted after me posting. Looking at it now, the second will print sort of a word list, but with duplicates and punctuation characters. Not sure what you want to do with it.

Let's start over. Please rephrase your request not in prose but in a concise, detailed, data supported, IT related specification. Like (let me try to paraphrase what I understood from your post #1):

  • Need to connect to a server using the ( ssh / telnet / rlogin / ...) tool / protocol and a known username.
  • The password is hidden in a text file.
  • Create a deduplicated word list from that file and use this for repeated login attempts.
  • The server has these ... password restrictions (to eliminate improbable candidates)
  • The server will pause logins after ... failed login attempts.
  • On successful login, retrieve an e-mail address form ... file.
  • Logout
  • Mail success message to retrieved address before date / time

Correct, adapt, and complete to suit your needs, and post again. The we can discuss.

If you're asking about the proposal I made in post #2 for getting a word list from a text file: The input to tr ( man tr !) is redirected ( < , man bash or other shell) from a file "textfile".
As any other info on how to continue was missing in your post #1, that is where I had to stop.