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 05:10
Suppose we have a byte addressable computer that has a 32-byte cache with 8 bytes per block. the memory address is 8 bits long. the system accesses memory addresses (in hex) in this exact order: 6e, b9, 17, e0, 4e, 4f, 50, 91, a8, ab, ad, 93, and 94. (a) assuming the cache is direct mapped, what memory addresses will be in cache block 2 after the last address has been accessed? (b) assuming the cache is direct mapped, what is the hit ratio for the entire memory reference sequence given, assuming the cache is initially empty? (c) assuming the cache is 2-way set associative with a lru replacement policy, what is the hit ratio?
Answers: 3
question
Computers and Technology, 22.06.2019 08:00
What is the algorithm for building a binary tree program
Answers: 2
question
Computers and Technology, 23.06.2019 00:20
Ihave been given the number of guns per 100, and the total firearm-related deaths per 100,000. i have to find the actual number of guns per country and actual number of gun-related deaths. if somebody could show me how to do 1 question, i can finish the rest, i am just confused. tia
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
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
History, 14.09.2020 22:01
question
Social Studies, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
History, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
History, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
History, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
Mathematics, 14.09.2020 22:01
question
English, 14.09.2020 22:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
Questions on the website: 13722362