Python Forum
Simple Cryptography Capture the Flag
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Cryptography Capture the Flag
#1
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.
Reply
#2
Are you looking for "flag" or the value of flag i.e.: flag = "easy_peezy_lemon_squeezy" within the text file?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
I'm looking for a string with "flag{something_in_here}" in the file
Reply
#4
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])
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
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.
Reply
#6
(Oct-12-2016, 09:41 PM)ichabod801 Wrote: Do you mean something like this?
"flag" doesn't appear in their input.
Reply
#7
(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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#8
(Oct-12-2016, 10:41 PM)wavic Wrote: I don't see '}' neither.
Damn that's a good point.
Reply
#9
(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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#10
Sorry, totally misunderstood the question.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help in using Flag pretty please kamui123 1 1,614 Oct-20-2020, 09:42 AM
Last Post: Larz60+
  Cryptography Problem PYTHONEUR 28 17,606 Jan-25-2017, 08:15 AM
Last Post: PYTHONEUR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020