Skip to content

YlmzCmlttn

Cemalettin Yılmaz Blog

Menu
  • Home
  • About Me
  • Projects
    • Iot-AR
    • Magnifi-AR
    • Smarthome-IOS
    • Others
  • Categories
    • Articles
    • Augmented Reality
    • Capture The Flag
      • Google CTF
        • 2018
    • Embedded Systems
    • IoT
    • Logisim
    • My Essays
    • Nvidia Jetson
      • Jetson TX1
    • Operating Systems
      • Kali
      • Raspbian
      • Ubuntu
    • Personal
    • Programming
      • Arduino
      • C
      • C#
      • Css
      • Html
      • Js
      • Matlab
      • Node.js
      • Python
      • Swift
      • VHDL
    • Projects
      • Embedded Systems
      • Electric
      • IoT
      • IoT-AR
      • Logisim
      • Magnifi-AR
      • Pose Estimation
    • Raspberry Pi
    • Xilinx
    • Others
Menu

Drive to target | Google CTF 2019

Posted on July 7, 2019July 7, 2019 by Yılmaz Cemalettin

Google CTF 2019

Drive to target

Excellent work! With your fine sleuthing skills, you managed to find a picture of the handsome creature with its pet biped. At last friends and companionship may be near! Like all inhabitants of this world, you spend an inordinate amount of time on the site, stalking and comparing your life to that of others. The first thought that springs to your mind is “Why haven’t I ever been to Mauritius on holiday?” followed swiftly by “What is a Mauritius anyway?” But after a while and with language successfully deciphered, you’ve made contact with the lifeform in the picture, you have a “date”? You’re given the address of where to meet your potential interest. “1 Banana way, beware of the glass.” An odd address, especially that last part. So how do you get there? You land your ship and begin to search.

https://drivetothetarget.web.ctfcompetition.com/

You can find my all CTF solution in here

Website;

When I try to picking different condition I saw the returned message. So I try to different option than I saw the 4 different option

These are conditions. So we must write to code manage these condition. First we must to be understand idea. First we find the direction. So that we must to calculate direction angle. These are the first step. After that code try to find optimal speed. Program must be increase the speed until gettin too fast error. I shar the code. If you have question about the calculating angle or anthing else. Please contact to me.

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python3.6
import math
import re
import time
import requests
from bs4 import BeautifulSoup
class Car:
    def __init__ (self):
        self.response = request(init=True)
        self.lat = self.response.lat
        self.lon = self.response.lon
        self.token = self.response.token
        self.angle = 0
        self.steps_counter = 0
        self.calculate_angle()
        self.step_size = 0.0001
    
    def drive(self):
        self.step()
        while not self.response.done():
            while self.response.closer():
                self.print()
                time.sleep(1)
                if self.response.speed() < 48:
                    self.step_size *= 1.001
                if self.steps_counter > 400:
                    self.calculate_angle()
                else:
                    self.steps_counter += 1
                self.step()
            if self.response.away():
                self.print()
                self.calculate_angle()
                self.step_size = 0.0001
                self.step()
            elif self.response.fast():
                self.print()
                self.step_size *= 0.99
                self.step()
            elif self.response.done():
                self.print()
                return self.response
        self.print() #this is not neccesary dump
    def calculate_angle(self):
        print('Calculating Angle ', end='')
        last_status = None
        self.steps_counter = 0
        for angle in range(0,361,1):
            print('.',end='',flush=True)
            distance = move(angle,0.0001)
 
            response = request(self.lat + distance.y,self.lon + distance.x, self.token)
            while response.fast():
                time.sleep(1)
                response = request(self.lat + distance.y,self.lon + distance.x, self.token)
            if response.done():
                self.angle = angle
                print()
                return
            status = 'away' if response.away() else 'closer'
            if status == 'closer' and last_status == 'away':
                self.angle = angle +89
                print()
                return
            else:
                last_status = status    
    def print(self):
        print(f'{self.response.msg} \nlat: {self.response.lat:.15f} \nlon: {self.response.lon:.15f}' f' \nangle: {self.angle}° \nURL: {self.response.url}')
    def step(self):
        distance=move(self.angle,self.step_size)
        response = request(self.lat + distance.y,self.lon+distance.x,self.token)
        if response.closer():
            self.lat = response.lat
            self.lon = response.lon
            self.token = response.token
        self.response = response
 
class Distance:
    def __init__(self,x,y):
        self.x = x
        self.y = y
 
class Responser:
    def __init__(self,msg,lat,lon,token,url):
        self.msg = msg
        self.lat = lat
        self.lon = lon
        self.token = token
        self.url = url
    
    def closer(self):
        return 'getting closer' in self.msg
 
    def away(self):
        return 'getting away' in self.msg
    
    def fast(self):
        return 'too fast' in self.msg
    
    def notmove(self):
        return 'you should move' in self.msg
    
    def speed(self):
        return int(re.findall('\\b(\\d+)km/h',self.msg)[0])
    
    def url(self):
        return self.url
    def done(self):
        return not (self.closer() or self.away() or self.fast() or self.notmove())
 
def move(angle,distance):
    rad = math.radians(angle)
    dx = math.sin(rad)*distance
    dy = math.cos(rad)*distance
    return Distance(dx,dy)
    
def request(lat=None, lon=None, token=None, init=False):
    if init:
        link = 'https://drivetothetarget.web.ctfcompetition.com/'
    else:
        link = f'https://drivetothetarget.web.ctfcompetition.com/?lat={lat}&lon={lon}&token={token}'
    
    soup = BeautifulSoup(requests.get(link).text,'html.parser')
 
    msg = soup.find_all('p')[-1].get_text()
    new_lat = float(soup.find('input', {'name': 'lat'}).get('value'))
    new_lon = float(soup.find('input', {'name': 'lon'}).get('value'))
    new_token = soup.find('input', {'name': 'token'}).get('value')
    return Responser(msg, new_lat, new_lon, new_token,link)
 
if __name__ == '__main__':
    car = Car()
    car.drive()

Sample output of the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
./car.py
Calculating Angle ...............................................................................................................................
You went 9m at a speed of 0km/h. You are getting closer…
lat: 51.649718084795573
lon: 0.098142642356365
angle: 215°
URL: https://drivetothetarget.web.ctfcompetition.com/?lat=51.64971808479557&lon=0.09814264235636488&token=gAAAAABdInPilUgkQz6REctDFNUxJrobuZVR0-8Q9FxJ_slYth_hZ7athseH7eSX3yW0q0f813XadvtTP2kAmfkqlatHbvsjOyb9Ifj7LGXuRQtl1_KxF9az0yBeEQyuSrAfVY7B9SNK
You went 9m at a speed of 21km/h. You are getting closer…
lat: 51.649636087675937
lon: 0.098085227355086
angle: 215°
URL: https://drivetothetarget.web.ctfcompetition.com/?lat=51.64963608767594&lon=0.09808522735508614&token=gAAAAABdInQ6jzbzv9igRb9xXPEIJ2nPODV8ARhhnikbn2tnk7sF6P28vdTP7WSXygqtw7wic6pyVxELiWorxYr5RcaSlG44uGKXM37K10wphVt7KmOL5jDew-RFjkx6n7f6JhIhboQI
You went 9m at a speed of 23km/h. You are getting closer…
lat: 51.649554008559186
lon: 0.098027754938806
angle: 215°
URL: https://drivetothetarget.web.ctfcompetition.com/?lat=51.649554008559186&lon=0.09802775493880612&token=gAAAAABdInQ7_eYZpiGEFDyA_VI6kqB9WGCFHPAi-nDwUof4Y1it8QPuUn3lbA1ocY4b6cf1GmqJSfs8uWO8Zy1yVDSsJGTJZCG3Fjpt2bO6JP3ls4QuK3Gmc1e7YvxpjEIYkltMQc23

When program finish it gives the website url. When you click on this website you will see the flag.

1
2
3
4
5
Congratulations, you made it, here is the flag:  CTF{Who_is_Tardis_Ormandy}
lat: 51.492141786931363
lon: -0.192798677264271
angle: 232°
URL: https://drivetothetarget.web.ctfcompetition.com/?lat=51.49214178693136&lon=-0.19279867726427113&token=gAAAAABdIoJ6DwkT_AGqP6jMRiueRRJ7vwTcIr0qnwwqDGsBySqyRA4Gibc-3v4MXa4UPsDxm6S6Ulg6GtRPTwYPiWtYIhY7Ia1rR_KnpKOTVj3pCDjF4Mpby7qohdZ0DWCeLtd1VeTa

https://drivetothetarget.web.ctfcompetition.com/?lat=51.49214178693136&lon=-0.19279867726427113&token=gAAAAABdIoJ6DwkT_AGqP6jMRiueRRJ7vwTcIr0qnwwqDGsBySqyRA4Gibc-3v4MXa4UPsDxm6S6Ulg6GtRPTwYPiWtYIhY7Ia1rR_KnpKOTVj3pCDjF4Mpby7qohdZ0DWCeLtd1VeTa

CTF{Who_is_Tardis_Ormandy}

 

1 thought on “Drive to target | Google CTF 2019”

  1. PIYUSH SARRAF says:
    July 21, 2019 at 10:50 am

    how do you manage to dubug such a hard question
    HATS OFF!!

    Reply

Leave a Reply to PIYUSH SARRAF Cancel reply

Your email address will not be published. Required fields are marked *

My Motto

“Learn to share, Share to learn”

LinkedIn Badge

Cemalettin Yılmaz

Ads

Archives

Categories

  • Articles (1)
  • Augmented Reality (3)
  • Capture The Flag (23)
    • Google CTF (22)
      • 2018 (13)
      • 2019 (9)
    • PicoCTF (1)
      • 2019 (1)
  • Embedded Systems (3)
  • IoT (3)
  • Logisim (1)
  • My Essays (3)
  • Nvidia Jetson (5)
    • Xavier (5)
  • Operating Systems (24)
    • Kali (3)
    • Raspbian (2)
    • Ubuntu (21)
  • Others (1)
  • Personal (1)
  • Programming (44)
    • Arduino (4)
    • C (10)
    • C# (4)
    • C++ (5)
    • Css (1)
    • CUDA (6)
    • Html (1)
    • Js (2)
    • Libraries (5)
      • OpenCV (3)
      • OpenGL (2)
    • Matlab (14)
    • Node.js (5)
    • Python (6)
    • Swift (3)
  • Programs (4)
    • Tools (4)
  • Projects (21)
    • Books Solutions (8)
    • Electric (2)
    • Embedded Systems (2)
    • Energy Harvesting (1)
    • IoT (2)
    • IoT-AR (1)
    • Logisim (1)
    • Magnifi-AR (3)
    • Pose Estimation (3)
    • Smarthome-Ios (1)
  • Raspberry Pi (3)
  • Uncategorized (2)
  • YZlib (1)

Recent Posts

  • atof stof stod problems with local floating point separator in C/C++
  • Pico CTF 2019 Answers
  • YZlib: Personal C++ Library
  • Drive to target | Google CTF 2019
  • FriendSpaceBookPlusAllAccessRedPremium | Google CTF 2019

Recent Comments

  • AbaShelha on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Peter on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Yılmaz Cemalettin on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Yılmaz Cemalettin on 16-Bit CPU on Logisim
  • Jenny on 16-Bit CPU on Logisim
  • MOON on 16-Bit CPU on Logisim
  • anti on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • hunkerjr on STOP GAN | Google CTF 2019
  • Shaq on 16-Bit CPU on Logisim
  • NURUL AFIQAH MOHD HASBULLAH on 16-Bit CPU on Logisim

Linkedln

© 2022 YlmzCmlttn | Powered by Superbs Personal Blog theme