Computers and Technology
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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:00, kamilahmcneil3969
What are the most likely causes of conflict at the meeting? check all that apply.
Answers: 1
image
Computers and Technology, 22.06.2019 07:00, yyy77uh
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e. g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
image
Computers and Technology, 22.06.2019 08:10, autumnguidry1622
Technician a says that if a valve is open when a piston rises to the very top of a cylinder, the piston may actually strike the valve head and cause serious engine damage. technician b says if the camshaft is located in the engine block, then the engine is called an overhead valve engine, ohv engine, or an in-block camshaft. who is right? a. b only b. both a and b c. a only d. neither a nor b
Answers: 3
image
Computers and Technology, 22.06.2019 16:00, sdonachy7
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
Do you know the correct 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
Mathematics, 19.08.2021 21:00
Konu
Mathematics, 19.08.2021 21:00