summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2017-10-26 09:55:42 -0400
committerBrian Potchik <brian@vector35.com>2017-10-26 09:55:42 -0400
commitc3c9be356d686a68b73422f17ccca67286d85b21 (patch)
tree9a45adbf13c593c4124373e0d3c263348c635931
parent7cbb40a71ffb2583862191b7999e436807f9a0e8 (diff)
parent77e09a2d02efbb2d6aa9758b503e37cbe7655f7f (diff)
Merge branch 'dev'
-rw-r--r--binaryninjaapi.cpp51
-rw-r--r--binaryninjaapi.h8
-rw-r--r--binaryninjacore.h8
-rw-r--r--docs/getting-started.md5
-rw-r--r--docs/guide/troubleshooting.md8
-rw-r--r--python/__init__.py7
-rw-r--r--python/basicblock.py2
-rw-r--r--python/binaryview.py71
-rw-r--r--python/update.py2
-rw-r--r--update.cpp4
10 files changed, 152 insertions, 14 deletions
diff --git a/binaryninjaapi.cpp b/binaryninjaapi.cpp
index aac92d7c..b774cf2b 100644
--- a/binaryninjaapi.cpp
+++ b/binaryninjaapi.cpp
@@ -65,6 +65,39 @@ void BinaryNinja::SetBundledPluginDirectory(const string& path)
}
+string BinaryNinja::GetUserDirectory(void)
+{
+ char* dir = BNGetUserDirectory();
+ if (!dir)
+ return string();
+ string result(dir);
+ BNFreeString(dir);
+ return result;
+}
+
+
+string BinaryNinja::GetSettingsFileName()
+{
+ char* dir = BNGetSettingsFileName();
+ if (!dir)
+ return string();
+ string result(dir);
+ BNFreeString(dir);
+ return result;
+}
+
+
+string BinaryNinja::GetRepositoriesDirectory()
+{
+ char* dir = BNGetRepositoriesDirectory();
+ if (!dir)
+ return string();
+ string result(dir);
+ BNFreeString(dir);
+ return result;
+}
+
+
string BinaryNinja::GetInstallDirectory()
{
char* path = BNGetInstallDirectory();
@@ -140,6 +173,15 @@ string BinaryNinja::GetVersionString()
}
+string BinaryNinja::GetLicensedUserEmail()
+{
+ char* str = BNGetLicensedUserEmail();
+ string result = str;
+ BNFreeString(str);
+ return result;
+}
+
+
string BinaryNinja::GetProduct()
{
char* str = BNGetProduct();
@@ -158,6 +200,15 @@ string BinaryNinja::GetProductType()
}
+string BinaryNinja::GetSerialNumber()
+{
+ char* str = BNGetSerialNumber();
+ string result = str;
+ BNFreeString(str);
+ return result;
+}
+
+
int BinaryNinja::GetLicenseCount()
{
return BNGetLicenseCount();
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 1ac60625..a6276b00 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -561,6 +561,10 @@ namespace BinaryNinja
std::string GetBundledPluginDirectory();
void SetBundledPluginDirectory(const std::string& path);
+ std::string GetUserDirectory();
+
+ std::string GetSettingsFileName();
+ std::string GetRepositoriesDirectory();
std::string GetInstallDirectory();
std::string GetUserPluginDirectory();
@@ -571,8 +575,10 @@ namespace BinaryNinja
std::string& output, std::string& errors, bool stdoutIsText=false, bool stderrIsText=true);
std::string GetVersionString();
+ std::string GetLicensedUserEmail();
std::string GetProduct();
std::string GetProductType();
+ std::string GetSerialNumber();
int GetLicenseCount();
bool IsUIEnabled();
uint32_t GetBuildId();
@@ -2965,7 +2971,7 @@ namespace BinaryNinja
static std::vector<UpdateChannel> GetList();
- bool AreUpdatesAvailable();
+ bool AreUpdatesAvailable(uint64_t* expireTime, uint64_t* serverTime);
BNUpdateResult UpdateToVersion(const std::string& version);
BNUpdateResult UpdateToVersion(const std::string& version,
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 1bb4c726..870c2de3 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -1203,7 +1203,8 @@ extern "C"
{
UpdateFailed = 0,
UpdateSuccess = 1,
- AlreadyUpToDate = 2
+ AlreadyUpToDate = 2,
+ UpdateAvailable = 3
};
struct BNUpdateChannel
@@ -1603,7 +1604,10 @@ extern "C"
BINARYNINJACOREAPI char* BNGetVersionString(void);
BINARYNINJACOREAPI uint32_t BNGetBuildId(void);
+ BINARYNINJACOREAPI char* BNGetSerialNumber(void);
+ BINARYNINJACOREAPI uint64_t BNGetLicenseExpirationTime(void);
BINARYNINJACOREAPI bool BNIsLicenseValidated(void);
+ BINARYNINJACOREAPI char* BNGetLicensedUserEmail(void);
BINARYNINJACOREAPI char* BNGetProduct(void);
BINARYNINJACOREAPI char* BNGetProductType(void);
BINARYNINJACOREAPI int BNGetLicenseCount(void);
@@ -2769,7 +2773,7 @@ extern "C"
BINARYNINJACOREAPI BNUpdateVersion* BNGetUpdateChannelVersions(const char* channel, size_t* count, char** errors);
BINARYNINJACOREAPI void BNFreeUpdateChannelVersionList(BNUpdateVersion* list, size_t count);
- BINARYNINJACOREAPI bool BNAreUpdatesAvailable(const char* channel, char** errors);
+ BINARYNINJACOREAPI bool BNAreUpdatesAvailable(const char* channel, uint64_t* expireTime, uint64_t* serverTime, char** errors);
BINARYNINJACOREAPI BNUpdateResult BNUpdateToVersion(const char* channel, const char* version, char** errors,
bool (*progress)(void* ctxt, uint64_t progress, uint64_t total),
diff --git a/docs/getting-started.md b/docs/getting-started.md
index d91eb046..692c1e67 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -27,16 +27,17 @@ The base locations of user folders are:
Contents of the user folder includes:
-- `settings.json`: Advanced settings (see [settings](#settings))
- `lastrun`: A text file containing the directory of the last BinaryNinja binary path -- very useful for plugins to resolve the install locations in non-default settings or on linux.
+- `license.dat`: License file
- `plugins/`: Folder containing all manually installed user plugins
- `repositories/`: Folder containing files and plugins managed by the [Plugin Manager API](https://api.binary.ninja/binaryninja.pluginmanager-module.html)
+- `settings.json`: Advanced settings (see [settings](#settings))
![license popup >](/images/license-popup.png "License Popup")
## License
-When you first run Binary Ninja, it will prompt you for your license key. You should have received your license key via email after your purchase. If not, please contact [support].
+When you first run Binary Ninja, it will prompt you for your license key. You should have received your license key via email after your purchase. If not, please contact [support](https://binary.ninja/support).
Once the license key is installed, you can change it, back it up, or otherwise inspect it simply by looking inside the base of the user folder for `license.dat`.
diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md
index a640d47e..c1b3a910 100644
--- a/docs/guide/troubleshooting.md
+++ b/docs/guide/troubleshooting.md
@@ -72,6 +72,14 @@ $ ln -s libssl.so libssl.so.1.0.0
$ ln -s libcrypto.so libcrypto.so.1.0.0
```
+Alternatively, you might need to (as root):
+
+```
+apt-get install libssl-dev
+ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
+ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
+```
+
### Gentoo
One Gentoo user [reported][issue672] a failed SSL certificate when trying to update. The solution was to copy over `/etc/ssl/certs/ca-certificates.crt` from another Linux distribution.
diff --git a/python/__init__.py b/python/__init__.py
index f4a8fac8..729e4f8a 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -21,6 +21,7 @@
import atexit
import sys
+from time import gmtime
# Binary Ninja components
import _binaryninjacore as core
@@ -147,6 +148,12 @@ core_version = core.BNGetVersionString()
core_build_id = core.BNGetBuildId()
'''Build ID'''
+core_serial = core.BNGetSerialNumber()
+'''Serial Number'''
+
+core_expires = gmtime(core.BNGetLicenseExpirationTime())
+'''License Expiration'''
+
core_product = core.BNGetProduct()
'''Product string from the license file'''
diff --git a/python/basicblock.py b/python/basicblock.py
index 72f31876..26db925d 100644
--- a/python/basicblock.py
+++ b/python/basicblock.py
@@ -140,7 +140,7 @@ class BasicBlock(object):
target = self._create_instance(self.view, core.BNNewBasicBlockReference(edges[i].target))
else:
target = None
- result.append(BasicBlockEdge(branch_type, self, target, edges[i].backEdge))
+ result.append(BasicBlockEdge(branch_type, target, self, edges[i].backEdge))
core.BNFreeBasicBlockEdgeList(edges, count.value)
return result
diff --git a/python/binaryview.py b/python/binaryview.py
index d002b38f..9304d412 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -88,10 +88,15 @@ class BinaryDataNotification(object):
class StringReference(object):
- def __init__(self, string_type, start, length):
+ def __init__(self, bv, string_type, start, length):
self.type = string_type
self.start = start
self.length = length
+ self.view = bv
+
+ @property
+ def value(self):
+ return self.view.read(self.start, self.length)
def __repr__(self):
return "<%s: %#x, len %#x>" % (self.type, self.start, self.length)
@@ -408,6 +413,18 @@ class Segment(object):
self.flags = flags
@property
+ def executable(self):
+ return (self.flags & SegmentFlag.SegmentExecutable) != 0
+
+ @property
+ def writable(self):
+ return (self.flags & SegmentFlag.SegmentWritable) != 0
+
+ @property
+ def readable(self):
+ return (self.flags & SegmentFlag.SegmentReadable) != 0
+
+ @property
def end(self):
return self.start + self.length
@@ -416,9 +433,9 @@ class Segment(object):
def __repr__(self):
return "<segment: %#x-%#x, %s%s%s>" % (self.start, self.end,
- "r" if (self.flags & SegmentFlag.SegmentReadable) != 0 else "-",
- "w" if (self.flags & SegmentFlag.SegmentWritable) != 0 else "-",
- "x" if (self.flags & SegmentFlag.SegmentExecutable) != 0 else "-")
+ "r" if self.readable else "-",
+ "w" if self.writable else "-",
+ "x" if self.executable else "-")
class Section(object):
@@ -659,6 +676,50 @@ class BinaryView(object):
"""
_BinaryViewAssociatedDataStore.set_default(name, value)
+ @property
+ def basic_blocks(self):
+ """A generator of all BasicBlock objects in the BinaryView"""
+ for func in self:
+ for block in func.basic_blocks:
+ yield block
+
+ @property
+ def llil_basic_blocks(self):
+ """A generator of all LowLevelILBasicBlock objects in the BinaryView"""
+ for func in self:
+ for il_block in func.low_level_il.basic_blocks:
+ yield il_block
+
+ @property
+ def mlil_basic_blocks(self):
+ """A generator of all MediumLevelILBasicBlock objects in the BinaryView"""
+ for func in self:
+ for il_block in func.medium_level_il.basic_blocks:
+ yield il_block
+
+ @property
+ def instructions(self):
+ """A generator of instruction tokens and their start addresses"""
+ for block in self.basic_blocks:
+ start = block.start
+ for i in block:
+ yield (i[0], start)
+ start += i[1]
+
+ @property
+ def llil_instructions(self):
+ """A generator of llil instructions"""
+ for block in self.llil_basic_blocks:
+ for i in block:
+ yield i
+
+ @property
+ def mlil_instructions(self):
+ """A generator of mlil instructions"""
+ for block in self.mlil_basic_blocks:
+ for i in block:
+ yield i
+
def __del__(self):
for i in self.notifications.values():
i._unregister()
@@ -2601,7 +2662,7 @@ class BinaryView(object):
strings = core.BNGetStringsInRange(self.handle, start, length, count)
result = []
for i in xrange(0, count.value):
- result.append(StringReference(StringType(strings[i].type), strings[i].start, strings[i].length))
+ result.append(StringReference(self, StringType(strings[i].type), strings[i].start, strings[i].length))
core.BNFreeStringReferenceList(strings)
return result
diff --git a/python/update.py b/python/update.py
index be6962d7..1eb8ea61 100644
--- a/python/update.py
+++ b/python/update.py
@@ -154,7 +154,7 @@ class UpdateChannel(object):
def updates_available(self):
"""Whether updates are available (read-only)"""
errors = ctypes.c_char_p()
- result = core.BNAreUpdatesAvailable(self.name, errors)
+ result = core.BNAreUpdatesAvailable(self.name, None, None, errors)
if errors:
error_str = errors.value
core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
diff --git a/update.cpp b/update.cpp
index 135fee5e..0ec69892 100644
--- a/update.cpp
+++ b/update.cpp
@@ -67,10 +67,10 @@ vector<UpdateChannel> UpdateChannel::GetList()
}
-bool UpdateChannel::AreUpdatesAvailable()
+bool UpdateChannel::AreUpdatesAvailable(uint64_t* expireTime, uint64_t* serverTime)
{
char* errors;
- bool result = BNAreUpdatesAvailable(name.c_str(), &errors);
+ bool result = BNAreUpdatesAvailable(name.c_str(), expireTime, serverTime, &errors);
if (errors)
{