我正在使用 C2Intel Feeds 来查找特定的可观察值,当我这样做时,我想提取/切出该行。
如果您转到链接/CSV 文件,我可以找到特定的 IP...即 - 54.161.191.72。
我想切掉整行:
www.e-enroll-benefits.com,可能的 Cobalt Strike C2 域名,/enrollmentinfo/,54.161.191.72
由于每一行都不同,我不确定如何完成这个过程。 我想找到长度,但不确定如何实现,因为它各不相同。
感谢任何帮助/指导。
谢谢你,
ip_address = "54.161.191.72"
lines = "https://raw.githubusercontent.com/drb-ra/C2IntelFeeds/master/feeds/domainC2swithURLwithIP-filter-abused.csv"
for line in lines:
if re.match("ip_address", line):
values_slice = line.split(": ")[-1]#not sure how you get the whole row?
我尝试了更简单的方法,它对我有用。 我没有访问 url,而是将 css 文件下载到本地文件夹。理想情况下,与运行 python 脚本的文件夹相同。 请看下面:
import os
os.chdir('/Users/***/***/') # please change this path to yours
ip_address = '54.161.191.72'
lines = open('domainC2swithURLwithIP-filter-abused.csv')
for line in lines:
if ip_address in line:
print(line)
很高兴回答您的任何问题。干杯!