ohjeongwook / binkit Goto Github PK
View Code? Open in Web Editor NEWBinary Reverse Engineering Data Science Kit
Binary Reverse Engineering Data Science Kit
typedef int va_t; -> address length
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py 1>tests.log
FEE.FF.
======================================================================
ERROR: test_dump_basic_blocks (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 89, in test_dump_basic_blocks
json.dump(basic_block_data_list, fd, indent = 4)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\__init__.py", line 179, in dump
for chunk in iterable:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\encoder.py", line 429, in _iterencode
yield from _iterencode_list(o, _current_indent_level)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\encoder.py", line 325, in _iterencode_list
yield from chunks
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\encoder.py", line 284, in _iterencode_list
raise ValueError("Circular reference detected")
ValueError: Circular reference detected
MatchRateInfo *DiffAlgorithms::GetMatchRateInfoArray(va_t source_address, va_t target_address, int type, int& match_rate_info_count)
.text:0045BC65
.text:0045BC65 ; Attributes: bp-based frame
.text:0045BC65
.text:0045BC65 ; void __stdcall jpeg_idct_islow_x86(jpeg_decompress_struct *cinfo, jpeg_component_info *compptr, __int16 *coef_block, char **output_buf, unsigned int output_col)
.text:0045BC65 _jpeg_idct_islow_x86@20 proc near
.text:0045BC65
.text:0045BC65 workspace= dword ptr -120h
.text:0045BC65 cinfo= dword ptr 8
.text:0045BC65 compptr= dword ptr 0Ch
.text:0045BC65 coef_block= dword ptr 10h
.text:0045BC65 output_buf= dword ptr 14h
.text:0045BC65 output_col= dword ptr 18h
.text:0045BC65
.text:0045BC65 push ebp
.text:0045BC66 mov ebp, esp
.text:0045BC68 mov eax, [ebp+cinfo]
.text:0045BC6B mov eax, [eax+148h]
.text:0045BC71 sub esp, 120h
.text:0045BC77 add eax, 80h ; '€'
0045BC65 = 4570213
6c833dd1 - 44402c (size: 70)
1820540369 - 4472876
Within same function, there are multiple instruction hash matches.
.text:0040C78A ; void __thiscall GPath::AddLineTo(GPath *this, float x, float y)
.text:0040C78A ?AddLineTo@GPath@@QAEXMM@Z proc near
0040C78A == 4245386 = RVA: 51082
1820313516 (0x6C7FC7AC) - 4245424, 4245504, 4245509
{
"source_parent": 0,
"target_parent": 0,
"source": 1820313516,
"target": 4245424,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820313516,
"target": 4245504,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820313516,
"target": 4245509,
"match_rate": 100
},
"source": 1820313516, 6C7FC7AC
.text:6C7FC7AC cmp edx, 1
.text:6C7FC7AF jnz loc_6C7FC85D
"target": 4245424 (40C7B0)
.text:0040C7B0 cmp edx, 1
.text:0040C7B3 jnz loc_40C861
.text:0040C800 cmp eax, 2
.text:0040C803 jz short loc_40C833
.text:0040C805 cmp eax, 5
.text:0040C808 jnz short loc_40C865
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>copy /y ..\x64\Debug\*.pyd .
..\x64\Debug\pybinkit.pyd
The process cannot access the file because it is being used by another process.
0 file(s) copied.
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py TestCase.test_function_match 1>test_function_match.log
F
======================================================================
FAIL: test_function_match (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 373, in test_function_match
function_matches = self.do_instruction_hash_match()
File "tests.py", line 369, in do_instruction_hash_match
self.assertTrue(self.util.compare_function_matches(expected_matches, matches))
AssertionError: False is not true
----------------------------------------------------------------------
Ran 1 test in 2.850s
FAILED (failures=1)
======================================================================
FAIL: test_do_instruction_hash_match_in_functions (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 218, in test_do_instruction_hash_match_in_functions
self.assertEqual(expected_instruction_matches, instruction_matches)
AssertionError: Lists differ: [{'so[71 chars]20562989, 'target': 4495475, 'match_rate': 100[679 chars]100}] != [{'so[71 chars]20562884, 'target': 4495378, 'match_rate': 100[431 chars]100}]
First differing element 1:
{'source': 1820562989, 'target': 4495475, 'match_rate': 100}
{'source': 1820562884, 'target': 4495378, 'match_rate': 100}
First list contains 4 additional elements.
First extra element 9:
{'source': 1820562904, 'target': 4495398, 'match_rate': 100}
Diff is 845 characters long. Set self.maxDiff to None to see it.
======================================================================
ERROR: test_dump_functions (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 137, in test_dump_functions
expected_function_data['basic_block_addresses'].sort()
TypeError: string indices must be integers
BOOL IDASessions::_Load()
{
...
const char *query = "";
if (ShowFullMatched)
{
if (ShowNonMatched)
{
query = "SELECT SourceAddress, EndAddress, TargetAddress, BlockType, MatchRate, SourceFunctionName, Type, TargetFunctionName, MatchCountForTheSource, NoneMatchCountForTheSource, MatchCountWithModificationForTheSource, MatchCountForTheTarget, NoneMatchCountForTheTarget, MatchCountWithModificationForTheTarget From "
FUNCTION_MATCH_INFO_TABLE
" WHERE TheSourceFileID=%u AND TheTargetFileID=%u";
}
else
{
query = "SELECT SourceAddress, EndAddress, TargetAddress, BlockType, MatchRate, SourceFunctionName, Type, TargetFunctionName, MatchCountForTheSource, NoneMatchCountForTheSource, MatchCountWithModificationForTheSource, MatchCountForTheTarget, NoneMatchCountForTheTarget, MatchCountWithModificationForTheTarget From "
FUNCTION_MATCH_INFO_TABLE
" WHERE TheSourceFileID=%u AND TheTargetFileID=%u AND MatchRate != 0";
}
}
else
{
if (ShowNonMatched)
{
query = "SELECT SourceAddress, EndAddress, TargetAddress, BlockType, MatchRate, SourceFunctionName, Type, TargetFunctionName, MatchCountForTheSource, NoneMatchCountForTheSource, MatchCountWithModificationForTheSource, MatchCountForTheTarget, NoneMatchCountForTheTarget, MatchCountWithModificationForTheTarget From "
FUNCTION_MATCH_INFO_TABLE
" WHERE TheSourceFileID=%u AND TheTargetFileID=%u AND (NoneMatchCountForTheSource != 0 OR NoneMatchCountForTheTarget != 0 OR MatchCountWithModificationForTheSource!=0 OR MatchCountWithModificationForTheTarget !=0 )";
}
else
{
query = "SELECT SourceAddress, EndAddress, TargetAddress, BlockType, MatchRate, SourceFunctionName, Type, TargetFunctionName, MatchCountForTheSource, NoneMatchCountForTheSource, MatchCountWithModificationForTheSource, MatchCountForTheTarget, NoneMatchCountForTheTarget, MatchCountWithModificationForTheTarget From "
FUNCTION_MATCH_INFO_TABLE
" WHERE TheSourceFileID=%u AND TheTargetFileID=%u AND (NoneMatchCountForTheSource != 0 OR NoneMatchCountForTheTarget != 0 OR MatchCountWithModificationForTheSource!=0 OR MatchCountWithModificationForTheTarget !=0 ) AND MatchRate != 0";
}
}
//TODO: FunctionMatchList = m_diffStorage->QueryFunctionMatches(query, SourceID, TargetID);
Return value filtering
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py TestCase.test_do_instruction_hash_match_in_functions 1>test_do_instruction_hash_match_in_functions.log
E
======================================================================
ERROR: test_do_instruction_hash_match_in_functions (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 238, in test_do_instruction_hash_match_in_functions
instruction_matches = self.do_instruction_hash_match_in_functions(0x6C83948B, 0x004496D9)
File "tests.py", line 230, in do_instruction_hash_match_in_functions
for match_data in diff_algorithms.do_blocks_instruction_hash_match(src_function.get_basic_blocks(), target_function.get_basic_blocks()):
AttributeError: 'NoneType' object has no attribute 'get_basic_blocks'
----------------------------------------------------------------------
Ran 1 test in 0.002s
FAILED (errors=1)
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py TestCase.test_dump_basic_blocks 1>test_dump_basic_blocks.log
F
======================================================================
FAIL: test_dump_basic_blocks (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 94, in test_dump_basic_blocks
self.assertEqual(expected_basic_block_data_list_pair, basic_block_data_list_pair)
AssertionError: Lists differ: [[{'a[213 chars]s': [{'type': 0, 'address': 1820573373}, {'typ[9606406 chars][]}]] != [[{'a[213 chars]s': [], 'parents': []}, {'address': 1820312476[8063418 chars][]}]]
First differing element 0:
[{'ad[212 chars]s': [{'type': 0, 'address': 1820573373}, {'typ[4825426 chars] []}]
[{'ad[212 chars]s': [], 'parents': []}, {'address': 1820312476[3282438 chars] []}]
Diff is 31916560 characters long. Set self.maxDiff to None to see it.
----------------------------------------------------------------------
Ran 1 test in 705.597s
FAILED (failures=1)
else
{
m_diffDisassemblyStorage->InsertMatchMap(SourceController->GetFileID(),
TargetController->GetFileID(),
*source_member_iter,
*target_member_iter,
FINGERPRINT_INSIDE_FUNCTION_MATCH,
current_match_rate);
}
pMatchResults->Erase(match_data.Addresses[0], match_data.Addresses[1]);
======================================================================
FAIL: test_function_pair_diffs (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 395, in test_function_pair_diffs
self.do_function_pair_diff(0x6c7fc779, 0x40c78a)
File "tests.py", line 391, in do_function_pair_diff
self.assertEqual(expected_function_diff_list, function_diff_list)
AssertionError: Lists differ: [{'fu[75 chars]ource': 1820313663, 'target': 4245540, 'match_[4875 chars]]}]}] != [{'fu[75 chars]ource_parent': 0, 'target_parent': 0, 'source'[3199 chars]]}]}]
First differing element 0:
{'fun[74 chars]ource': 1820313663, 'target': 4245540, 'match_[1947 chars]6]}]}
{'fun[74 chars]ource_parent': 0, 'target_parent': 0, 'source'[1437 chars]0]}]}
Diff is 23556 characters long. Set self.maxDiff to None to see it.
======================================================================
FAIL: test_dump_basic_blocks (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 108, in test_dump_basic_blocks
self.assertEqual(expected_basic_block_data_list, basic_block_data_list)
AssertionError: Lists differ: [[{'a[27 chars]l': 'error_exit', 'instruction_hash': [143, 1,[9606692 chars][]}]] != [[{'a[27 chars]l': '', 'instruction_hash': [143, 18, 122, 18,[8686798 chars][]}]]
First differing element 0:
[{'ad[26 chars]l': 'error_exit', 'instruction_hash': [143, 1,[4825685 chars] []}]
[{'ad[26 chars]l': '', 'instruction_hash': [143, 18, 122, 18,[4366139 chars] []}]
Diff is 54714313 characters long. Set self.maxDiff to None to see it.
----------------------------------------------------------------------
Ran 1 test in 940.372s
binary = pybinkit.Binary()
if self.debug_level > 0:
print('Opening %s...' % filename)
binary.open(filename)
======================================================================
FAIL: test_instruction_hash_match (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 190, in test_instruction_hash_match
self.assertEqual(expected_match_data_list, match_data_list)
AssertionError: Lists differ: [{'source': 1820540761, 'target': 4473268, 'match_rate': [1626967 chars]0}]}] != [{'source': 1820607143, 'target': 4539756, 'match_rate': [1110499 chars]0}]}]
First differing element 0:
{'source': 1820540761, 'target': 4473268, 'match_rate': [118 chars]00}]}
{'source': 1820607143, 'target': 4539756, 'match_rate': [118 chars]00}]}
Diff is 4194703 characters long. Set self.maxDiff to None to see it.
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>copy /y ..\x64\Debug\*.pyd .
..\x64\Debug\pybinkit.pyd
The process cannot access the file because it is being used by another process.
0 file(s) copied.
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py TestCase.test_dump_functions 1>test_dump_functions.log
F
======================================================================
FAIL: test_dump_functions (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 158, in test_dump_functions
self.compare_function_list(expected_function_data_list_pair[i], current_function_data_list_pair[i])
File "tests.py", line 136, in compare_function_list
self.assertTrue(address in current_address_to_function_data_map)
AssertionError: False is not true
----------------------------------------------------------------------
Ran 1 test in 1.067s
FAILED (failures=1)
Remove from DiffAlgorithms -> ClientAnalysisInfo
Using various packages
I:\ReverseEngineering\Tools\Vulnerabilities\DarunGrim\Src\binkit\tests>python tests.py TestCase.test_instruction_hash_match 1>test_instruction_hash_match.log
F
======================================================================
FAIL: test_instruction_hash_match (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 219, in test_instruction_hash_match
self.assertEqual(expected_match_data_list, match_data_list)
AssertionError: Lists differ: [{'source': 1820312448, 'target': 4244352,[1110514 chars]0}]}] != []
First list contains 5009 additional elements.
First extra element 0:
{'source': 1820312448, 'target': 4244352, 'match_rate': 100, 'child_match_list': []}
Diff is 1993814 characters long. Set self.maxDiff to None to see it.
----------------------------------------------------------------------
Ran 1 test in 2.038s
FAILED (failures=1)
{
"source": 1820314868,
"target": 4246735,
"matches": [
{
"source_parent": 0,
"target_parent": 0,
"source": 1820314868,
"target": 4246735,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820314909,
"target": 4246776,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820314933,
"target": 4246800,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820314933,
"target_parent": 4246800,
"source": 1820315070,
"target": 4246944,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820314933,
"target_parent": 4246800,
"source": 1820315077,
"target": 4246944,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315082,
"target": 4246949,
"type": 4,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315094,
"target": 4246961,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820315082,
"target_parent": 4246949,
"source": 1820315103,
"target": 4247148,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315123,
"target": 4246990,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820315123,
"target_parent": 4246990,
"source": 1820315241,
"target": 4247108,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315272,
"target": 4247139,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820315272,
"target_parent": 4247139,
"source": 1820315281,
"target": 4247148,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315301,
"target": 4247168,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820315301,
"target_parent": 4247168,
"source": 1820315419,
"target": 4247286,
"type": 6,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315445,
"target": 4247312,
"type": 1,
"sub_type": 0,
"match_rate": 100
}
]
},
{
"source_parent": 0,
"target_parent": 0,
"source": 1820315094,
"target": 4246961,
"type": 1,
"sub_type": 0,
"match_rate": 100
},
{
"source_parent": 1820315103,
"target_parent": 4247148,
"source": 1820315094,
"target": 4247139,
"type": 6,
"sub_type": 0,
"match_rate": 90
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.