Probably not the prettiest solution, but the below code seems to be working.

chars = 0
ln = 0
for count, line in enumerate(file):
    if chars < cn:
    for char in line:
        chars += 1
    else: break
print count


On Sunday, February 21, 2016 at 1:36:26 PM UTC-6, Cody West wrote:
>
> Hi, 
>
> I'm fairly new to python and could use some assistance here.
>
> I'm using yara-python 
> <http://yara.readthedocs.org/en/latest/yarapython.html> for some file 
> scanning and I'm trying to take the offset in the 'strings' field and turn 
> it into a line number.
>
> Below is what I'm working with.
>
> (48L, '$execution', 'eval(base64_decode')
>
>
> I'm trying to take 48L, which I believe is the character number, and get 
> the line number from that.
>
> I know how to count lines until I match a string, but this is a little 
> harder.
>
> I've searched all over the tubes and I can't seem to find anything useful. 
> Help a beginner out?
>
> Thanks for your time,
> Cody W
>

-- 
You received this message because you are subscribed to the Google Groups 
"YARA" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to