I wrote the following socket code for the (capture the flag) exercise, need help concatenating data received from the server, as seen in the screenshot.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I wrote the following socket code for the (capture the flag) exercise, need help concatenating data received from the server, as seen in the screenshot. 

 

#####################################################################

import socket

import sys

import threading


 

HOST = 'cyber210.network'

PORT = 8002

BUFFER_SIZE = 4096


 

# Create a socket object and connect to the server

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

with socket.socket() as s:

    s.connect((HOST, PORT))


 

    # Define a function to be called for each line received from the server

    def handle_line(line):

        if line.startswith('>'):

            clean_line = line[1:]

            try:

                result = str(eval(clean_line)) + '\n'

                print(clean_line, result)

                s.sendall(result.encode())

            except Exception as e:

                print(f'Error evaluating line {clean_line}: {e}')


 

    # Receive data from the server and process each line

    

    while True:

        data = s.recv(BUFFER_SIZE).decode()

        if not data:

            print('End of program')

            sys.exit(1)

        else: 

          #received_data += data

          print(f'data recv: {data}')

          for line in data.splitlines():

              handle_line(line)

    s.close()

##################################################################

CO
=
२
_x}
15s
File Edit View Insert Runtime Tools Help All changes saved
+ Code + Text
# defense system has flagged your session as suspicious.
# Please evaluate this additional set of expressions to prove your identity.
> 209072770 + 855293395
> 81666123 + 901972634
> 782986164 + 362494923
209072778 +855293395 1064366165
81666123 +901972634 983638757
782986164 + 362494923 1145481087
data recv: # Thank you! We will now transfer you to the command system.
# Your authentication token is _flag_{be12659a1110c0acf6af0f18cb77d159}.
data recv: # ...
data recv: #
data recv: #
data recv: # Hi! We unfortunately experience some hiccups today and require
# manual authentication on the command system again.
data recv: > 2
22
data recv: 7
data recv: 528
data recv: 727
data recv: 8 +
data recv:
data recv: 98274
data recv: 8
data recv: 47
data recv:
data recv: Errors in your calculations? HUMAN! HUMAN! HUMAN!
End of program
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
SEARCH STACK OVERFLOW
Transcribed Image Text:CO = २ _x} 15s File Edit View Insert Runtime Tools Help All changes saved + Code + Text # defense system has flagged your session as suspicious. # Please evaluate this additional set of expressions to prove your identity. > 209072770 + 855293395 > 81666123 + 901972634 > 782986164 + 362494923 209072778 +855293395 1064366165 81666123 +901972634 983638757 782986164 + 362494923 1145481087 data recv: # Thank you! We will now transfer you to the command system. # Your authentication token is _flag_{be12659a1110c0acf6af0f18cb77d159}. data recv: # ... data recv: # data recv: # data recv: # Hi! We unfortunately experience some hiccups today and require # manual authentication on the command system again. data recv: > 2 22 data recv: 7 data recv: 528 data recv: 727 data recv: 8 + data recv: data recv: 98274 data recv: 8 data recv: 47 data recv: data recv: Errors in your calculations? HUMAN! HUMAN! HUMAN! End of program An exception has occurred, use %tb to see the full traceback. SystemExit: 1 SEARCH STACK OVERFLOW
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY