Bandit 18
Objectives
There are 2 files in the homedirectory: passwords.old and passwords.new. The password for the next level is in passwords.new and is the only line that has been changed between passwords.old and passwords.new
NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into bandit18, this is related to the next level, bandit19
Solution
let's grep with some switches
-F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-x, --line-regexp Select only those matches that exactly match the whole line.
-f , --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing.
-v, --invert-match Invert the sense of matching, to select non-matching lines.
now in python
so from this output we can see there are two lines that only appear in each of the files, hence the + and - sign in front of the two lines. from our python we know that passwords.new is designated by the minus sign
Objectives
There are 2 files in the homedirectory: passwords.old and passwords.new. The password for the next level is in passwords.new and is the only line that has been changed between passwords.old and passwords.new
NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into bandit18, this is related to the next level, bandit19
Solution
let's grep with some switches
-F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-x, --line-regexp Select only those matches that exactly match the whole line.
-f , --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing.
-v, --invert-match Invert the sense of matching, to select non-matching lines.
bandit17@bandit:~$ grep -Fxvf passwords.old passwords.newkfBf3eYk5BPBRzwjqutbbfE887SVc5Yd
now in python
>>> import difflib>>> new = open("passwords.new").readlines()>>> old = open("passwords.old").readlines()>>> >>> for line in difflib.unified_diff(new,old, fromfile='passwords.new', tofile='passowrds.old'):
... print line,
--- passwords.new+++ passowrds.old@@ -39,7 +39,7 @@ gZ5U640FLMMChheWKHNdaQ1lKzLuqjxZ Al0xVJb5bEzhnFG8nPFe6IJa2FjXVSzo CT2ZJy6MoLkTqdHuhL5zUIsW41WCntAA-kfBf3eYk5BPBRzwjqutbbfE887SVc5Yd+hlbSBPAWJmL6WFDb06gpTx1pPButblOA 46lUvvv0JJzyY0IOhWgGp5IjfsllmvaC FcSd4Me936rwbk2pAU9ylx9NXTrzdCaX vfU4mCzATtqUMNLg3a7mPs3OY6Dr4jaZ
so from this output we can see there are two lines that only appear in each of the files, hence the + and - sign in front of the two lines. from our python we know that passwords.new is designated by the minus sign
Comments
Post a Comment