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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
Which of the following statements tests if students have a grade of 70 or above, as well as fewer than five absences? a: if(grade > = 70 and daysabsent < = 5): b: if(grade > = 70 or daysabsent < = 5): c: if(grade > 70 and daysabsent < = 5): d: if(grade > 70 or daysabsent < = 5): i took the test the answer is a
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
Martha is a healer, a healthcare provider, and an experienced nurse. she wants to share her daily experiences, as well as her 12 years of work knowledge, with people who may be interested in health and healing. which mode of internet communication can martha use?
Answers: 3
question
Computers and Technology, 23.06.2019 06:00
Which statement is true of web-based social media? a.they allow consumers to interact with and update content. b.they cannot be updated easily, as compared to print media. c.they are expensive to produce and maintain, as compared to print and television. d.they can exist independent of the internet.
Answers: 1
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
question
Mathematics, 16.04.2021 19:40
question
Mathematics, 16.04.2021 19:40
question
Mathematics, 16.04.2021 19:40
question
Mathematics, 16.04.2021 19:40
question
Mathematics, 16.04.2021 19:40
question
Mathematics, 16.04.2021 19:40
Questions on the website: 13722363