subject
Computers and Technology, 09.08.2021 23:40 brae72

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(" print("Status: ", hex(status))
print("Partition Type: ", hex(partitionType))
print("Address of First Sector: ", firstSectorAddress[0])
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(' print('Address of the first sector in the partition: ', addr[0])
s. send(int(addr[0], 0))
s. close()
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

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, ghazanfarwaheed7967
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
image
Computers and Technology, 24.06.2019 06:30, titalili0204
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
image
Computers and Technology, 24.06.2019 08:30, ladybuggirl400
@josethesolis i need can anyone text me and follow me
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, brusawerin5969
Refer to the figure and match the theorem that supports the statement.1.if chords are =, then arcs are =.if bc = de, then arc bc = arc de2.if arcs are =, then chords are =.if arc bc = arc de, then bc = de3.diameters perpen
Answers: 3
You know the right answer?
This question was asked before by someone else but the solution did not work and it didn't work for...

Questions in other subjects:

Konu
Biology, 30.09.2020 07:01
Konu
Mathematics, 30.09.2020 07:01
Konu
Mathematics, 30.09.2020 07:01
Konu
History, 30.09.2020 07:01