Comments (3)
Okay. You caught me. I was being lazy and didn't want to implement the decoding of all the available strtype
s since db.get.string()
works regardless of whether a string is defined at the address or not and lets you specify the length too.
The reason why idaapi.get_strlit_contents(ea, idaapi.get_item_size(ea), idaapi.get_str_type(ea))
never made it into db.get.string
is because it actually utf8 encodes utf-16le (or any mbcs really). This changes the bytes in the actual string when really it should return it as a unicode
type. So to preserve those bytes, I always just used .rstrip()
and then .decode()
on all the strings I read from a database.
An example of this utf8-encoding on a utf-16le string (IDA 7.1.180227): 9a 3f 43 56 4f 54 57 3e 43 62 00 00
Python>repr(idaapi.get_strlit_contents(h(), idaapi.get_item_size(h()), idaapi.get_str_type(h())))
'\xe3\xbe\x9a\xe5\x99\x83\xe5\x91\x8f\xe3\xb9\x97\xe6\x89\x83'
But then with db.get.string()
, if you process it you get the following correct string.
Python>repr(db.get.string().decode('utf-16le'))
u'\u3f9a\u5643\u544f\u3e57\u6243\x00'
I just didn't want to implement all of the ASCSTR types, but I guess I will.
Since you're only using C-style strings, you can put something like the following in your ~/.idapythonrc.py
until I get it done.
db.get.string = staticmethod(fcompose(db.get.string, operator.methodcaller('rstrip')))
from ida-minsc.
@x0rloser, PR #21 should fix this. I submitted the PR for review, then I reviewed my own code and realized that I'm just so awesome and so I merged it upstream because I'm always right and of course it fixes the issue...so, yeah...
Anyways, you should just need to do a git pull
to re-sync, and you should be good to go. It supports the other stuff without needing UTF-8 like I mentioned. If that didn't fix it for you for some reason or there's some particular case I missed, just re-open this issue and lmk.
Thanks for your contribution, sir
from ida-minsc.
can confirm is fixed (for C strings at least). awesomeness ftw ;)
from ida-minsc.
Related Issues (20)
- Minor readability improvement of bool HOT 3
- Rename argument name "direction" to something better like "options" HOT 5
- Do not replace the os.sep HOT 5
- Suggestion: When doing the refactoring, drop support for Python 2 and older IDA HOT 3
- Using the name "binary" for a program is confusing when there is a file format in IDA named "binary file" HOT 4
- Suggestion: Add the name DLL as that is what IDA calls the shared objects HOT 2
- Add a comment that this value will be updated when a new file is loaded HOT 1
- Suggestion: If you drop support for older Python, then you can add type hints HOT 3
- Minor doc change: says "all" but only 1 is returned HOT 3
- Maybe duplication of code? bits() vs bitsize() HOT 3
- Wrong path on windows HOT 2
- Using double quotation marks makes this work on Windows also HOT 2
- The instruction namespace should return a ida_ua.insn_t() object instead of a string HOT 3
- An InvalidTypeOrValue exception is being raised when trying to fetch the type for a function being listed. HOT 20
- Docs: Quick start is wrong, the example code throws exception HOT 1
- Suggestion: Add documention on how to use IDA-minsc together with the plugin ipyida HOT 7
- Rename go --> jumpto (since the term go usually means "let the debugger run" in RE) HOT 3
- Rename argument "none" to a better name since it is very easy to missread it as None HOT 3
- Replace idaapi.read_selection() with ida_kernwin.read_range_selection() HOT 3
- Inability to access the attributes of netnodes that use a tag of 0. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ida-minsc.