ProxyAuth
Linux PAM to authenticate device via Bluetooth device
Macros | Functions
deauth.c File Reference

A background program that runs as soon as you are authenticated to check if your device is nearby. It'll lock the computer if the device is not nearby. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <errno.h>
#include <limits.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include "pam_misc.h"
#include "pam_bt_misc.h"
#include "pam_bt_pair.h"
#include "pam_bt_trust.h"
#include "proxy_dbus.h"
Include dependency graph for deauth.c:

Go to the source code of this file.

Macros

#define SERVICE_NAME   "Proxy Auth"
 
#define SERVICE_DESC   "Continuous Authentication via Bluetooth"
 
#define SERVICE_PROV   "ProxyAuth"
 
#define minThroughput   100
 

Functions

sdp_session_t * sdp_connect (const bdaddr_t *src, const bdaddr_t *dst, uint32_t flags)
 
int sdp_close (sdp_session_t *session)
 
int sdp_record_register (sdp_session_t *sess, sdp_record_t *rec, uint8_t flags)
 
void terminate_server (int server, int client, sdp_session_t *session)
 
void set_service (uuid_t *svc_uuid, uuid_t *svc_class_uuid, sdp_list_t **svc_class_list, sdp_record_t *record, uint32_t *svc_uuid_int)
 
void set_bluetooth_service_info (sdp_profile_desc_t *profile, sdp_list_t **profile_list, sdp_record_t *record)
 
void set_browsable (sdp_list_t **root_list, sdp_record_t *record, uuid_t *root_uuid)
 
void set_l2cap_info (sdp_list_t **l2cap_list, sdp_list_t **proto_list, uuid_t *l2cap_uuid)
 
void register_rfcomm_sock (sdp_data_t **channel, sdp_record_t *record, sdp_list_t **rfcomm_list, sdp_list_t **proto_list, sdp_list_t **access_proto_list, uuid_t *rfcomm_uuid, uint8_t *rfcomm_channel)
 
sdp_session_t * register_service (uint8_t rfcomm_channel)
 
int init_server (struct sockaddr_rc *loc_addr, sdp_session_t **session)
 
void lock (struct dbus_obj *data_obj)
 
int check_arg (int argc, char **argv)
 
int is_trusted_client (char *bt_addr, const char *trusted_dir_path)
 
int connect_client (int s, struct sockaddr_rc *rem_addr, socklen_t *opt, char *authorized_dev, struct dbus_obj *data_obj)
 
int main (int argc, char **argv)
 

Detailed Description

A background program that runs as soon as you are authenticated to check if your device is nearby. It'll lock the computer if the device is not nearby.

Special Thanks to: Ryan Scott for providing how to register service and Albert Huang

Definition in file deauth.c.

Macro Definition Documentation

◆ minThroughput

#define minThroughput   100

Definition at line 29 of file deauth.c.

◆ SERVICE_DESC

#define SERVICE_DESC   "Continuous Authentication via Bluetooth"

Definition at line 27 of file deauth.c.

◆ SERVICE_NAME

#define SERVICE_NAME   "Proxy Auth"

Definition at line 26 of file deauth.c.

◆ SERVICE_PROV

#define SERVICE_PROV   "ProxyAuth"

Definition at line 28 of file deauth.c.

Function Documentation

◆ check_arg()

int check_arg ( int  argc,
char **  argv 
)

Return 1 iff the given bluetooth address in the argument is valid

Parameters
argcnumber of arguments (always >= 1 due to program name stored in argv[0])
argvarray that contains cmdline arguments
Returns
: True iff the cmd argument is a valid bluetooth address

Definition at line 258 of file deauth.c.

Here is the call graph for this function:

◆ connect_client()

int connect_client ( int  s,
struct sockaddr_rc *  rem_addr,
socklen_t *  opt,
char *  authorized_dev,
struct dbus_obj data_obj 
)

Connect a new client. If client is not from a trusted device nor authorized then lock the system.

Parameters
sserver's socket
rem_addra pointer to sockaddr structure that will store the address of the client socket
optthe size of rem_addr
authorized_devthe address of the trusted device
server_dataa struct that contains fd that needs to be closed before termination
Returns
: The client's socket

Definition at line 324 of file deauth.c.

Here is the call graph for this function:

◆ init_server()

int init_server ( struct sockaddr_rc *  loc_addr,
sdp_session_t **  session 
)

Setup the bluetooth server

Returns
return the server's socket file descriptor

Definition at line 216 of file deauth.c.

Here is the call graph for this function:

◆ is_trusted_client()

int is_trusted_client ( char *  bt_addr,
const char *  trusted_dir_path 
)

Return 1 iff the given bluetooth address is trusted and paired

Parameters
bt_addrthe address of the bluetooth to check
Returns
: True iff given bluetooth address is a trusted and pired device

Definition at line 277 of file deauth.c.

Here is the call graph for this function:

◆ lock()

void lock ( struct dbus_obj data_obj)

Lock the computer, cleanup memory and open fd, and terminate program

Parameters
server_dataa struct that contains fd that needs to be closed and all the dbus references needed

Definition at line 243 of file deauth.c.

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 343 of file deauth.c.

Here is the call graph for this function:

◆ register_rfcomm_sock()

void register_rfcomm_sock ( sdp_data_t **  channel,
sdp_record_t *  record,
sdp_list_t **  rfcomm_list,
sdp_list_t **  proto_list,
sdp_list_t **  access_proto_list,
uuid_t *  rfcomm_uuid,
uint8_t *  rfcomm_channel 
)

register the RFCOMM channel for RFCOMM sockets

Definition at line 115 of file deauth.c.

◆ register_service()

sdp_session_t* register_service ( uint8_t  rfcomm_channel)

Definition at line 135 of file deauth.c.

Here is the call graph for this function:

◆ sdp_close()

int sdp_close ( sdp_session_t *  session)

◆ sdp_connect()

sdp_session_t* sdp_connect ( const bdaddr_t *  src,
const bdaddr_t *  dst,
uint32_t  flags 
)

◆ sdp_record_register()

int sdp_record_register ( sdp_session_t *  sess,
sdp_record_t *  rec,
uint8_t  flags 
)

◆ set_bluetooth_service_info()

void set_bluetooth_service_info ( sdp_profile_desc_t *  profile,
sdp_list_t **  profile_list,
sdp_record_t *  record 
)

Set Bluetooth profile metadata for the service and the version of the profile

Definition at line 86 of file deauth.c.

◆ set_browsable()

void set_browsable ( sdp_list_t **  root_list,
sdp_record_t *  record,
uuid_t *  root_uuid 
)

Make the service record publicly browsable. Allows remote bluetooth devices to see the service record.

Definition at line 97 of file deauth.c.

◆ set_l2cap_info()

void set_l2cap_info ( sdp_list_t **  l2cap_list,
sdp_list_t **  proto_list,
uuid_t *  l2cap_uuid 
)

set l2cap information

Definition at line 106 of file deauth.c.

◆ set_service()

void set_service ( uuid_t *  svc_uuid,
uuid_t *  svc_class_uuid,
sdp_list_t **  svc_class_list,
sdp_record_t *  record,
uint32_t *  svc_uuid_int 
)

Set the general service ID and service class

Parameters
svc_uuida pointer to store the generated service 128-bit UUID
svc_class_uuida pointer to store the generated Service Class UUID
svc_class_lista pointer to an array of service class uuid
record
svc_uuid_int

Definition at line 65 of file deauth.c.

◆ terminate_server()

void terminate_server ( int  server,
int  client,
sdp_session_t *  session 
)

Definition at line 44 of file deauth.c.

Here is the call graph for this function: