Question
This question was asked before by someone else but the solution did not work and it didn't work for me either. Below is the question:
This question was asked before by someone else but the solution did not work and it didn't work for me either. Below is the question:
I am to build on the program from last week(posted below). Use the same file from last week. You will be extracting the first partition entry from the master boot record that is contained in the file. The first partition entry starts at offset 0x1BE and ends at 0x1CD. Pull that chunk of bytes out of the file provided and send it to the server software that you will write. The server will listen for the chunk of data and print out the status of the drive, the partition type and the starting address of the partition as an integer.
LAST WEEK'S CODE:
import struct data = bytearray() # Open the block.dd to read and parse with open('block.dd', 'rb') as file: ____data = file.read() # Parse and assign partition status byte status = data[0x1BE] # Parse and assign partition type byte partitionType = data[0x1C2] # Parse, unpack, and assign address of first sector of partition (4 bytes) firstSectorAddress = struct.unpack("
THE CODE I HAVE FOR THIS WEEK SO FAR:
CLIENT FILE:
import struct import socket f = open('block.dd', 'rb') mbr = bytearray() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostname() port = 8888 s.connect(('172.0.0.1', 8888)) print(s.recv(1024)) try: mbr = f.read(2048) s.send(mbr) finally: f.close() status = mbr[0x1BE] if status == 0x80: print('Status: Active') s.send('Status: Active') ptype = mbr[0x1BE+4] print('Partition type:', ptype) s.send(ptype) addr = struct.unpack('
SERVER FILE:
import socket # Import socket module s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Create a socket object host = socket.gethostname() # Get local machine name port = 8888 # Reserve a port for your service. s.bind(('172.0.0.1', 8888)) # Bind to the port s.listen(5) # Now wait for client connection. while True: c, addr = s.accept() # Establish connection with client. print('Got connection from', + addr) c.send('Thank you for connecting') while 1: print(c.recv(2048)) c.close() # Close the connection
THANK YOU IN ADVANCE!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started