Python Forum

Full Version: Simple Cryptography Capture the Flag
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I don't really understand how I am supposed to change my code to work to print the proper flag out in the text.
The flag itself is 30 characters long. An example of what the flag would look like is: f l a g { e a s y _ p e a s y _ l e m o n _ s q u e e z y }

f = open("quad_radical.txt")

txt = f.read()

p = 0
count = 0
for i in range(30):
        p = count ** 2
        print txt[p]
        count = count + 1
The text file that I am looking through looks like this: 
Now I obviously can see the flag is in the beginning and it does up by a quadratic formula, but when I run the code I only get the "f" and "l" of flag. Please help. Sorry if my formatting is bad.
Are you looking for "flag" or the value of flag i.e.: flag = "easy_peezy_lemon_squeezy" within the text file?
I'm looking for a string with "flag{something_in_here}" in the file
Do you mean something like this?

text = 'A sentence with a flag{in it} somewhere.'
start = text.index('flag{') + 5
end = text.index('}', start + 1)
print(text[start:end])
I would simplify your loop code (though still wrong) to
for i in range(30):
   p = i ** 2
   print txt[p],
If you think you need more variables, then you should describe for us what they're supposed to do or be for, because I tried a few things and I'm not sure what change needs to be made either.
(Oct-12-2016, 09:41 PM)ichabod801 Wrote: [ -> ]Do you mean something like this?
"flag" doesn't appear in their input.
(Oct-12-2016, 09:49 PM)micseydel Wrote: [ -> ]
(Oct-12-2016, 09:41 PM)ichabod801 Wrote: [ -> ]Do you mean something like this?
"flag" doesn't appear in their input.

I don't see '}' either. Unless the key length is 122 symbols or something.
(Oct-12-2016, 10:41 PM)wavic Wrote: [ -> ]I don't see '}' neither.
Damn that's a good point.
(Oct-12-2016, 10:42 PM)micseydel Wrote: [ -> ]
(Oct-12-2016, 10:41 PM)wavic Wrote: [ -> ]I don't see '}' neither.
Damn that's a good point.

Don't be hurry! I had to edit my post. I was wondering 'either' or 'neither' to use  :D
Sorry, totally misunderstood the question.
Pages: 1 2