Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
andrwgldmn committed Mar 16, 2019
0 parents commit dcc78cd
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Shim_parser

Парсер логкатов для получения шимок локально и через Интернет

### Как использовать?

sudo apt-get install python-dev python3-dev python-requests

python Shim_parser.py

## ​----------​----------​----------​----------​----------​------------------​----------​----------​

# Shim_parser

Parsing logcat for getting shims (local and via Internet)

### How to use?

sudo apt-get install python-dev python3-dev python-requests

python Shim_parser.py
110 changes: 110 additions & 0 deletions Shim_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import re
import os
import requests

value = None
def help():
print (' ----------------------------')
print ('\n Eng:\n Put near this script your log.txt to work with 1 item, copy a link of your logcat from Web to work with 2 item. \n')
print (' \n Рус: Положите рядом со скриптом ваш log.txt с 1 пунктом, скопируйте ссылку на ваш логкат из сети для работы с 2 пунктом. \n ')
print (' \n Укр: Покладіть біля цього скрипта ваш log.txt для роботи з 1 пунктом, скопіюйте ссилку на ваш логкат з мережі для роботи з 2 пунктом. \n ')
print (' \n Made by andrwgldmn \n')
print (' ----------------------------')

def shimparser_inet():
with open('shims.c', 'w') as output_file:
url = raw_input(' Enter the URL: ')
r = requests.get(url)
text = r.text
pat = r"""cannot\s*locate\s*symbol\s*"(.+?)"\s*referenced\s*"""
for symbol in re.findall(pat, text):
part_one = "#include <stdint.h>\n\nvoid "
part_two = "{}".format(symbol)
part_three = "(){}\n"
shim = (part_one + part_two + part_three)
output_file.write(shim)

File = open('shims.c', 'r')
str_list = set()
for i in File.readlines():
if i not in str_list:
str_list.add(i)
File.close()
File = open('shims.c', 'w')
for j in str_list:
File.write(j)
os.system('cls' if os.name == 'nt' else 'clear')

def shimparser_local():
with open('log.txt') as input_file, open('shims.c', 'w') as output_file:
text = input_file.read()
pat = r"""cannot\s*locate\s*symbol\s*"(.+?)"\s*referenced\s*"""
for symbol in re.findall(pat, text):
part_one = "#include <stdint.h>\n\nvoid "
part_two = "{}".format(symbol)
part_three = "(){}\n"
shim = (part_one + part_two + part_three)
output_file.write(shim)

File = open('shims.c', 'r')
str_list = set()
for i in File.readlines():
if i not in str_list:
str_list.add(i)
File.close()
File = open('shims.c', 'w')
for j in str_list:
File.write(j)
os.system('cls' if os.name == 'nt' else 'clear')

help()

while value != 0:
help()
print (' ----------------------------')
value = int(input(" 1) English \n 2) Русский \n 3) Українська \n ---------------------------- \n "))
if (value != 1 and value != 2 and value != 3 ):
print ("\n Program has been terminated. \n" )
if (value == 1):
while value != 0:
print (' ----------------------------')
value = int(input(" Choose category: \n \n 0) Exit \n 1) Parsing local log.txt for getting shims \n 2) Parsing log.txt for getting shims rules via Internet (log.txt will be given from your entered URL) \n ---------------------------- \n "))

if (value == 0):
print('-' * 28 + '\n Thanks!\n' + '-' * 28)

elif (value == 1):
shimparser_local()

elif (value == 2 ):
shimparser_inet()

if (value == 2):
while value != 0:
print (' ----------------------------')
value = int(input(" Выберите категорию: \n \n 0) Выход \n 1) Анализ локального log.txt для получения шимок \n 2) Анализ log.txt для получения шимок через Internet (log.txt будет скачан по ссылке, которую Вы введёте. URL) \n ---------------------------- \n "))

if (value == 0):
print('-' * 28 + '\n Спасибо!\n' + '-' * 28)

elif (value == 1):
shimparser_local()

elif (value == 2 ):
shimparser_inet()

if (value == 3):
while value != 0:
print (' ----------------------------')
value = int(input(" Оберіть категорію: \n \n 0) Вихід \n 1) Аналіз локального log.txt для отримання шимок \n 2) Аналіз log.txt для отримання шимок через Internet (log.txt буде завантажений з URL, яку Ви введете) \n ---------------------------- \n "))

if (value == 0):
print('-' * 28 + '\n Дякую!\n' + '-' * 28)
elif (value == 1):
shimparser_local()

elif (value == 2 ):
shimparser_inet()

0 comments on commit dcc78cd

Please sign in to comment.