0

I have an output which looks like

________________________________________________

 :: Method           : GET
 :: URL              : HOST/FUZZ
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 500
 :: Matcher          : Response status: 200
________________________________________________

[Status: 200, Size: 52, Words: 2, Lines: 6]
    * FUZZ: index.jsp
    * HOST: https://test.com


what I want from this output is only two things contact them together

Expected output

https://test.com/index.jsp

what I tried already is

awk '/HOST:/{ print $4} /FUZZ:/{ print $4}' ffuf'

output

index.jsp
https://test.com

Hexdump output

grep 'FUZZ:' ffuf | hexdump -C

Output

00000000  0d 0d 20 20 20 20 2a 20  46 55 5a 5a 3a 20 69 6e  |..    * FUZZ: in|
00000010  64 65 78 2e 6a 73 70 0a                           |dex.jsp.|
00000018

any idea how to contact them together?

thanks

12
  • Shouldn't it be $3 instead of $4 in your example?
    – Freddy
    Commented May 9, 2020 at 8:58
  • nope. If I $3 the output was FUZZ: and HOST: only Commented May 9, 2020 at 9:04
  • There is space in front of the asterisk Commented May 9, 2020 at 9:05
  • 1
    There must be some strange characters in the output, not only spaces or tabs.
    – Freddy
    Commented May 9, 2020 at 9:10
  • 1
    Add output of grep 'FUZZ:' file | hexdump -C to your question.
    – Cyrus
    Commented May 9, 2020 at 9:33

2 Answers 2

1

From the hexdump output that you show, it's clear that there are two carriage return characters at the start of the lines containing the data that you're after. These would constitute the first field on those lines if you parsed the data using awk. Both variations (sed and awk) below work around this by either ignoring (sed) or avoiding (awk) these.


Using sed, and assuming that the line with FUZZ: always occurs before the line with HOST::

$ sed -n '/.*FUZZ: /{ s///; h; }; /.*HOST: /{ s///; G; s,\n,/,p; }' file
https://test.com/index.jsp

The sed command (which is run with the default outputting of every line turned off with -n) matches the FUZZ: line and deletes everything on it up until the filename. The filename is then copied to he hold space with h.

When the HOST: line is matched, the start of that line is likewise removed, and the contents of the hold space is appended to the URL (the remainder of the HOST: line). The newline inserted by the G command is then changed to a slash and the resulting string is printed.


Using awk, with the same assumption as above:

$ awk -v OFS='/' '/FUZZ:/ { fuzz = $NF } /HOST:/ { print $NF, fuzz }' file
https://test.com/index.jsp

Here, the variable fuzz plays the role of the hold space that we used in the sed variation above, i.e. to hold the filename. $NF is the data in the last field on a line.

1
  • thanks, I understood your solution. Commented May 9, 2020 at 9:58
-1

I achieve this by doing

awk '/FUZZ:/{ FUZZ=$4; next } /HOST:/{ print $4 "/" FUZZ }'

OUTPUT

https://test.com/index.jsp
5
  • Unless you expect HOST: and FUZZ: occurring on the same line, there is no need for next. Also, there is no fourth field in your data, so $4 will be empty.
    – Kusalananda
    Commented May 9, 2020 at 9:13
  • $3 is not working with my output. When I use $3 it prints the HOST: and FUZZ: only not the data I want Commented May 9, 2020 at 9:19
  • Copy and paste the data from your question and try your solution on that. Also, follow the advice from Cyrus in comments to the question.
    – Kusalananda
    Commented May 9, 2020 at 9:39
  • 1
    Added hexdump output as suggested. There might be some copy-paste mistake to output. Commented May 9, 2020 at 9:46
  • That line (and presumably all of them) starts with CR CR. Those are not treated as whitespace, so that is $1. Commented May 9, 2020 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .