- Learning Python for Forensics
- Preston Miller Chapin Bryce
- 258字
- 2021-08-20 10:17:12
Constructing the get_device_names() function
This function's purpose is to pass the VID and PID information into the usb_lookup library and return resolved USB names. As defined by the docstring mentioned later, this function takes two dictionaries—the first contains the database of known devices from prep_usb_lookup(), and the second contains the extracted device entries from parse_device_info(). With this provided data, we will return a dictionary, updated with resolved vendor and product names:
151 def get_device_names(usb_dict, device_info):
152 """
153 Query `usb_lookup.py` for device information based on VID/PID.
154 :param usb_dict: Dictionary from usb_lookup.py of known
155 devices.
156 :param device_info: Dictionary containing 'Vendor ID' and
157 'Product ID' keys and values.
158 :return: original dictionary with 'Vendor Name' and
159 'Product Name' keys and values
160 """
This function calls the usb_lookup.search_key() function, passing the processed online USB dictionary and a two-element list containing the device's VID and PID as the first and second element, respectively. The .search_key() function returns either a responsive match or the Unknown string if no matches are discovered. This data is returned as a tuple and assigned to the device_name variable on line 161. We then split the two resolved values into new keys of our device_info dictionary on lines 165 and 166. Once we have expanded device_info, we can return it so that it can be printed to the console. See the following lines:
161 device_name = usb_lookup.search_key(
162 usb_dict, [device_info['Vendor ID'],
163 device_info['Product ID']])
164
165 device_info['Vendor Name'] = device_name[0]
166 device_info['Product Name'] = device_name[1]
167
168 return device_info
- RESTful Java Web Services Security
- Extending Symfony2 Web Application Framework
- Securing Blockchain Networks like Ethereum and Hyperledger Fabric
- 計(jì)算機(jī)病毒分析與防范大全(第3版)
- Web安全與攻防入門很輕松(實(shí)戰(zhàn)超值版)
- 諸神之眼:Nmap網(wǎng)絡(luò)安全審計(jì)技術(shù)揭秘
- 網(wǎng)絡(luò)運(yùn)維親歷記 (網(wǎng)絡(luò)運(yùn)維紀(jì)實(shí)文學(xué))
- 物聯(lián)網(wǎng)安全滲透測(cè)試技術(shù)
- 數(shù)據(jù)要素安全:新技術(shù)、新安全激活新質(zhì)生產(chǎn)力
- 網(wǎng)絡(luò)安全實(shí)戰(zhàn)詳解(企業(yè)專供版)
- 網(wǎng)絡(luò)空間安全:拒絕服務(wù)攻擊檢測(cè)與防御
- 物聯(lián)網(wǎng)信息安全技術(shù)
- Hands-On Bug Hunting for Penetration Testers
- 企業(yè)安全建設(shè)入門:基于開源軟件打造企業(yè)網(wǎng)絡(luò)安全
- Python Penetration Testing Essentials