never stop questioning

ucp.c

ucp.c
Posted Jan 5, 2001
Authored by s0ftpj, Jack McKrak | Site s0ftpj.org

SMS Spoofing Tool - Spoof your SMS by using this code with smsclient.

tags | spoof
MD5 | 4893e2044a30ac7a59927d15e527537e

ucp.c

Change Mirror Download
/* -------------------------------------------------------------------- */

/* Variante del file ucp.c per sms_client 2.0.8r by JacK McKrak */

/* -------------------------------------------------------------------- */



#include <stdio.h>

#include <string.h>

#include <stdarg.h>



#include "common/common.h"

#include "logfile/logfile.h"

#include "driver.h"

#include "error.h"

#include "ascii.h"

#include "comms/comms.h"

#include "resource/resource.h"



/* -------------------------------------------------------------------- */



static struct ucp_env

{

DRIVER_DEFAULT_ENV def;



/* Place any extended driver */

/* variables here */



} driver_env;



/* -------------------------------------------------------------------- */



static RESOURCE resource_list[] =

{

{ RESOURCE_STRING, "SMS_comms_params",

0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params)

},

{ RESOURCE_STRING, "SMS_centre_number",

0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number)

},

{ RESOURCE_NUMERIC, "SMS_baud",

0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud)

},

{ RESOURCE_NUMERIC, "SMS_deliver_timeout",

0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout)

},

{ RESOURCE_NUMERIC, "SMS_timeout",

0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout)

},

{ RESOURCE_NUMERIC, "SMS_write_timeout",

0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout)

},

{ RESOURCE_NUMERIC, "SMS_max_deliver",

0, 0, NULL, 0, NULL, 1, &(driver_env.def.max_deliver)

},

{ RESOURCE_NULL, NULL,

0, 1, NULL, 0, NULL, 0, NULL

}

};



/* -------------------------------------------------------------------- */



#define DELIVERTIMEOUT (driver_env.def.deliver_timeout)

#define TIMEOUT (driver_env.def.timeout)

#define WRITETIMEOUT (driver_env.def.write_timeout)



/* -------------------------------------------------------------------- */



#define FD (driver_env.def.fd)



/* -------------------------------------------------------------------- */



static int UCP_sendmessage(char *msisdn, char *message);

static int UCP_parse_response(char *string);

static void UCP_hangup(void);

static char *UCP_generate_checksum(const char *fmt, ...);

static char *UCP_build_message(char *msisdn, char *message);

static char *UCP_build_transaction(int transaction_id, char transaction_type,

int operation_type, const char *fmt, ...);



/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

static char *UCP_generate_checksum(const char *fmt, ...)

{

va_list args;

static char buf[1024];

char *ptr;

int j;







va_start(args, fmt);

#if !defined(LINUX)

vsprintf(buf, fmt, args);

#else

vsnprintf(buf, 1024, fmt, args);

#endif

va_end(args);





/* ------------------------ */



j = 0;

for (ptr = buf; *ptr != '\0'; ptr++)

{

j += *ptr;



if (j >= 256)

{ j -= 256;

}

}



sms_snprintf(buf, 1024, "%02X", j);

return buf;

}





/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

static char *UCP_build_transaction(int transaction_id, char transaction_type,

int operation_type, const char *fmt, ...)

{

va_list args;

static char buf[1024];

char header[1024],

data[1024],

codestring[1024];



FILE *fcd;





va_start(args, fmt);

#if !defined(LINUX)

vsprintf(data, fmt, args);

#else

vsnprintf(data, 1024, fmt, args);

#endif

va_end(args);



/* ------------------------ */





fcd = fopen("codice","r");

fscanf(fcd,"%s",&codestring);

fclose(fcd);



sms_snprintf(header, 1024, "%02d/%05d/%c", transaction_id,

sms_strlen(data) + sms_strlen(codestring) + 15, transaction_type);



printf("<STX>%s/%s/%s/%s<ETX>\n",header,codestring,

data,UCP_generate_checksum("%s/%s/%s/",header,codestring,data));



sms_snprintf(buf, 1024, "%c%s/%s/%s/%s%c", S_STX,

header,

codestring,

data,

UCP_generate_checksum("%s/%s/%s/",

header, codestring, data),

S_ETX);



return buf;

}





/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

static char *UCP_build_message(char *msisdn, char *message)

{

char ia5_message[1024],

*src,

*dest;





dest = ia5_message;

for (src = message; *src != '\0'; src++)

{

sms_snprintf(dest, 1024, "%02X", *src);

dest += 2;

}



return UCP_build_transaction(1, 'O', 1, "%s", ia5_message);

}





/* -------------------------------------------------------------------- */

/* Return Values: */

/* 0 Positive ACK */

/* 1 Negative ACK */

/* -1 Error */

/* -------------------------------------------------------------------- */

static int UCP_parse_response(char *string)

{

int result;



int transaction,

length,

type,

checksum;



char ack,

recipient[64],

timestamp[64];



/* ------------------------------------------------------------ */

/* Example: */

/* <STX>01/00045/R/01/A/0041544180972:161298112313/A6<ETX> */

/* <STX>01/00019/R/01/A//69<ETX> */

/* ------------------------------------------------------------ */



result = sscanf(string, "\002%02d/%05d/R/%02d/%c/%16[^:]:%12s/%02X\003",

&transaction,

&length,

&type,

&ack,

recipient,

timestamp,

&checksum);



if (result != 7)

{

result = sscanf(string, "\002%02d/%05d/R/%02d/%c//%02X\003",

&transaction,

&length,

&type,

&ack,

&checksum);



if (result != 5)

{ return -1;

}

}



/* ---------------------------- */



result = -1;



if (ack == 'A')

{ result = 0;

}

else

if (ack == 'N')

{ result = 1;

}



return result;

}



/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

static int UCP_sendmessage(char *msisdn, char *message)

{

char buf[MAX_RESPONSE_BUFSIZE],

*ucp_message;



int result;





ucp_message = UCP_build_message(msisdn, message);

twrite(FD, ucp_message, sms_strlen(ucp_message), WRITETIMEOUT);



if (expstr(FD, buf, "\03", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0)

{

lprintf(LOG_STANDARD, "SMSC Respsonse: %s\n", buf);



result = UCP_parse_response(buf);

if (result == 0)

{

lprintf(LOG_STANDARD, "Received Acknowledgement\n");

}

else

if (result == 1)

{ lprintf(LOG_STANDARD, "Acknowledgement Failed\n");



UCP_hangup();

return EUCP_ACKFAILED;

}

else

{ lprintf(LOG_STANDARD, "Bad Acknowledgement\n");



UCP_hangup();

return EUCP_BADACK;

}

}

else

{ lprintf(LOG_STANDARD, "No Message Response\n");



UCP_hangup();

return EUCP_NORESPONSE;

}



return 0;

}



/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

static void UCP_hangup(void)

{ default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env));

}



/* -------------------------------------------------------------------- */

/* -------------------------------------------------------------------- */

DEVICE_ENTRY ucp_device = {



"UCP",

"1.0",

resource_list,

(DRIVER_DEFAULT_ENV *)(&driver_env),



default_init,

default_main,

default_validate_numeric_id,

default_dial,

default_hangup,

default_send_disconnect,

default_single_deliver,

UCP_sendmessage,

default_login

};

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close