@COBRAS
can you be more specific please? what do you mean by the link you posted?
EDIT: Oh I understood now. You were referring to the range slicer written in C++ by AlbertoBSD.
There it is. Will try it ... thanks for pointing out
I slightly changed the output format of the python script that n0nce provided, so I get pairwise ranges per each line. I added two small functions for later use (converting dec<>hex).
#!/usr/bin/python3
import sys
try: start = int(sys.argv[1])
except:
try: start = int(sys.argv[1], 16)
except: exit(-1)
try: end = int(sys.argv[2])
except:
try: end = int(sys.argv[2], 16)
except: exit(-1)
try: n = int(sys.argv[3])
except:
try: n = int(sys.argv[3], 16)
except: exit(-1)
size = (end-start)/n
# output in hex
#print(list(map(lambda x: (hex(int(start+x*size)), hex(int(start+size*(x+1)))), range(n))))
# output in decimal
#print(list(map(lambda x: (int(start+x*size), int(start+size*(x+1))), range(n))))
for x in range(n):
print((hex(int(start+x*size)), hex(int(start+size*(x+1)))))
def hex2int(hexdigits):
return int(hexdigits, 16)
def int2hex(number):
return hex(number)
When I compare the output of both snippets, they differ. I have no clue what the reason therefore is. See here ..
$ ./split_range.py 1 255 4
('0x1', '0x40')
('0x40', '0x80')
('0x80', '0xbf')
('0xbf', '0xff')
$ ./slicer 1 255 4
Range start: 0x1
Range end: 0xff
number: 0x4
slice value: 0x3f
1:40
40:7f
7f:be
be:fd
fd:13c
When user input is 2 slices the result matches between both programs:
$ ./split_range.py 1000 2000 2
('0x3e8', '0x5dc')
('0x5dc', '0x7d0')
$ ./slicer 1000 2000 2
Range start: 0x3e8
Range end: 0x7d0
number: 0x2
slice value: 0x1f4
3e8:5dc
5dc:7d0
Some more examples ...
$ ./split_range.py 1000 2000 7
('0x3e8', '0x476')
('0x476', '0x505')
('0x505', '0x594')
('0x594', '0x623')
('0x623', '0x6b2')
('0x6b2', '0x741')
('0x741', '0x7d0')
$ ./slicer 1000 2000 7
Range start: 0x3e8
Range end: 0x7d0
number: 0x7
slice value: 0x8e
3e8:476
476:504
504:592
592:620
620:6ae
6ae:73c
73c:7ca
7ca:858
here the output matches...
$ ./split_range.py 1000 2000 8
('0x3e8', '0x465')
('0x465', '0x4e2')
('0x4e2', '0x55f')
('0x55f', '0x5dc')
('0x5dc', '0x659')
('0x659', '0x6d6')
('0x6d6', '0x753')
('0x753', '0x7d0')
$ ./slicer 1000 2000 8
Range start: 0x3e8
Range end: 0x7d0
number: 0x8
slice value: 0x7d
3e8:465
465:4e2
4e2:55f
55f:5dc
5dc:659
659:6d6
6d6:753
753:7d0
I thought it might be the case when n is even or odd, but I find no relationship between odd/even numbers. See here, n=12 leads to different range pairs
$ ./split_range.py 1000 2000 12
('0x3e8', '0x43b')
('0x43b', '0x48e')
('0x48e', '0x4e2')
('0x4e2', '0x535')
('0x535', '0x588')
('0x588', '0x5dc')
('0x5dc', '0x62f')
('0x62f', '0x682')
('0x682', '0x6d6')
('0x6d6', '0x729')
('0x729', '0x77c')
('0x77c', '0x7d0')
$ ./slicer 1000 2000 12
Range start: 0x3e8
Range end: 0x7d0
number: 0xc
slice value: 0x53
3e8:43b
43b:48e
48e:4e1
4e1:534
534:587
587:5da
5da:62d
62d:680
680:6d3
6d3:726
726:779
779:7cc
7cc:81f
It seems that alberto's slicer tool sometimes creates one more additional range than user input was. Only the first range pair matches
always between both programs.