View Single Post
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#55
Originally Posted by R-R View Post
How is the IMSI protected ?
IMSI can be obtained in pretty much the same way as the IMEI.

Here's a quick dbus-send command-line example: dbus-send --system --type=method_call --print-reply=True --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi which returns one argument: an int32 with the IMSI.

Code:
/* gcc -Wall imsi_example.c -o imsi_example `pkg-config --cflags --libs glib-2.0 dbus-glib-1` */

#include <stdlib.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <dbus/dbus-glib.h>

#define SIM_DBUS_NAME  "com.nokia.phone.SIM"
#define SIM_DBUS_IFACE "Phone.Sim"
#define SIM_DBUS_PATH  "/com/nokia/phone/SIM"
#define SIM_IMSI_SIG  "get_imsi"

static gchar* get_imsi(DBusGConnection *connection)
{
  GError *error = NULL;
  DBusGProxy *proxy;
  gchar *imsi = NULL;
  guint32 tmp1;

  g_return_val_if_fail(connection, imsi);

  proxy = dbus_g_proxy_new_for_name(connection, SIM_DBUS_NAME, SIM_DBUS_PATH, SIM_DBUS_IFACE);
  if (!dbus_g_proxy_call(proxy, SIM_IMSI_SIG, &error, G_TYPE_INVALID, G_TYPE_STRING, &imsi, G_TYPE_INT, &tmp1, G_TYPE_INVALID))
  {
    if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
      g_printerr("Caught remote method exception %s: %s", dbus_g_error_get_name(error), error->message);
    else
      g_printerr("Failed to call method: %s\n", error->message);
    g_clear_error(&error);
  }
  g_object_unref(proxy);

  return imsi;
}

int main(void)
{
  GError *error = NULL;
  DBusGConnection *connection;
  gchar* imsi;

  g_type_init();

  connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
  if (!connection)
  {
    g_printerr("Failed to open connection to system bus: %s\n", error->message);
    g_clear_error(&error);
    return EXIT_FAILURE;
  }

  imsi = get_imsi(connection);
  (void) g_printf("%s\n", imsi ? imsi : "Failed to retrieve IMSI\n");
  if (!imsi)
    return EXIT_FAILURE;
  g_free(imsi);

  return EXIT_SUCCESS;
}

Last edited by qwerty12; 2009-11-11 at 15:13.
 

The Following 3 Users Say Thank You to qwerty12 For This Useful Post: