File size: 869 Bytes
a9640f8
 
 
 
 
 
 
 
 
 
 
 
 
 
8aec9fe
a9640f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd

def get_img_api(hash, data_path):
 
    df = pd.read_csv(data_path)
    
    
    row = df[df['SHA256'] == hash]
    

    if row.empty:
        return None, None
    
    # Extract the image path
    img_path = 'src/data/Images/' + row['SHA256'].values[0] + '.jpg'
    
    # Extract the API calls
    api_columns = df.columns[2:]  # Skip the first two columns (SHA256 and Type)
    api_calls = row[api_columns].values.flatten().tolist()
    
    # Filter out only the API calls that are present (value == 1)
    api_call_list = [[api for api, value in zip(api_columns, api_calls) if value == 1]]
    
    return img_path, api_call_list


# hash_value = '002ce0d28ec990aadbbc89df457189de37d8adaadc9c084b78eb7be9a9820c81'
# img_path, api_call_list = get_img_api(hash_value)

# print("Image Path:", img_path)
# print("API Call List:", api_call_list)