AF
Asterisk Forum
обсуждения телефонии, VoIP и IP-PBX
12разделов
5 423тем
34 385сообщений
← К списку тем

Linux From Scratch

Библиотека 3 сообщений -
#1

_______ __
| __|.-----.| |--..----..-----..----..-----.
|__ || -__|| < | __|| _ || _|| -__|
|_______||_____||__|__||____||_____||__| |_____|


- Asterisk & D-Link VTA -


Step 1.

Once you get your brand new VTA from your VOIP provider, do not connect it anywhere.
Turn the VTA up side down and take note of the MAC ID.
Setup and start a DHCP and TFTP server on your machine. (Laptop/Desktop)
Use a cross-over cable to connect your machine via the ethernet interface to the VTA directly.
Disable any other interface on your machine.

Step 2.

Power that VTA and follow this url: (xxx.xxx.xxx.xxx = DHCP IP address)
http://xxx.xxx.xxx.xxx
Username: user
Password: user

Then go to this URL:
http://xxx.xxx.xxx.xxx/cgi-bin/webcm?getpage=../html/advanced/adv_provision.htm


Step 3.

Cut and past the DEFAULT ${Encryption Key}
Cut and past the DEFAULT ${Provisioning File Path}
Cut and part the DEFAULT ${Provisioning Profile Base URL}

Step 4.

Turn off and disconnect your VTA.
Connect your machine to the internet.
Retreive the encrypted config using a TFTP client.
# tftp ${Provisioning Profile Base URL}
tftp> binary
tftp> get ${Provisioning File Path}/tiXXxxXXxxXXxx.xml

Example:
# tftp tftp.voipprovider.com
tftp> binary
tftp> get cpiTd1/ti00179A281342.xml

Step 5.

Decrypt the config file using this utility:
rc4 key < in > out

rc4 ${Encryption Key} < tiXXxxXXxxXXxx.xml > tiXXxxXXxxXXxx.xml-txt

Step 6. Use the account information from your VTA and use it on Asterisk.

Open tiXXxxXXxxXXxx.xml-txt
Write down the ${username} from 14188888888
Write down the ${password} from password1234
Write down the ${sipserver} from sip.voipprovider.com
Write down the ${sipserverport} from 5060

Edit your sip.conf from your Asterisk server:

------------------------------------------------------------------------
register=${username}:${password}@voipprovider

[voipprovider]
context = sip-incoming ; You may need to change this setting
insecure = very
disallow = all
allow = ulaw
port = ${sipserverport}
username = ${username}
type = peer
secret = ${password}
nat = yes
host = ${sipserver}
fromuser = ${username}
fromdomain = ${sipserver}
dtmfmode=rfc2833
auth=md5
outboundproxy=${sipserver}
outboundproxyport=${sipserverport}
------------------------------------------------------------------------

Reload Asterisk and Voila! Asterisk is now connected to your VoIP provider.

Step 7. Connect your VTA to Asterisk.

Once you have decrypted the config file, you can edit it.

Minimal changes:

tftp://YourOwnTftpServerIP:69,21,2400
YourOwnTftpServerIP
${Encryption Key}
${Provisioning File Path}
adminpassword
userpassword

123456
123456
quebec

YourAsteriskIP
5060
YourAsteriskIP
5060

Step 8.

Save this file using a different name.
Example: tiXXxxXXxxXXxx.xml-txt-NEW

Encrypt this file using this command line:
rc4 ${Encryption Key} < tiXXxxXXxxXXxx.xml-txt-NEW > tiXXxxXXxxXXxx.xml-NEW

Make a directory in your tftp server, place and rename the file (tiXXxxXXxxXXxx.xml-NEW) to:
${Provisioning File Path}/tiXXxxXXxxXXxx.xml

Step 9.

Disconect from the Internet.
On your machine, use dnsspoof or any other tools to redirect any dns requests to your own IP.
Connect and power up the VTA.

Step 10.

Follow this url: (xxx.xxx.xxx.xxx = DHCP IP address)
http://xxx.xxx.xxx.xxx
Username: Admin
Password: adminpassword

Go to Admin then VoIP and edit:

SIP Configuration - User Agent
Index 1
Phone Number 123456
Display Name VTALINE1
User Agent Port 10000
Authentication Username 123456
Password quebec
Retype Password quebec

SIP Configuration - Server
Index 1
IP Address YourAsteriskIP
Port 5060
Outbound Proxy IP Address YourAsteriskIP
Outbound Proxy Port 5060
Timer T2 32000
Register Expiration 60000
Session Expires 0
Min-SE 0

Press "Apply" then goto "Save & Reboot" and click on "Reboot"

Step 11.

Edit your sip.conf on your Asterisk server:

------------------------------------------------------------------------
[123456]
context = default ; You may need to change this setting
insecure = very
disallow = all
allow = ulaw
port = 5060
username = 123456
type = friend
secret = quebec
host = dynamic
fromuser = 123456
dtmfmode=rfc2833
nat=Yes
notransfer=yes
qualify=500

Reload Asterisk and Voila! Your VTA is now talking directly to your Asterisk.

MR 16-11-2006
www.sekcore.com
ANNEX: rc4.c

================================================================================
#include
#include

#define buf_size 1024

typedef struct rc4_key
{
unsigned char state[256];
unsigned char x;
unsigned char y;
} rc4_key;

#define swap_byte(x,y) t = *(x); *(x) = *(y); *(y) = t

void prepare_key(unsigned char *key_data_ptr, int key_data_len, rc4_key *key)
{
int i;
unsigned char t;
unsigned char swapByte;
unsigned char index1;
unsigned char index2;
unsigned char* state;
short counter;

state = &key->state[0];
for(counter = 0; counter < 256; counter++)
state[counter] = counter;
key->x = 0;
key->y = 0;
index1 = 0;
index2 = 0;
for(counter = 0; counter < 256; counter++)
{
index2 = (key_data_ptr[index1] + state[counter] + index2) % 256;
swap_byte(&state[counter], &state[index2]);
index1 = (index1 + 1) % key_data_len;
}
}

void rc4(unsigned char *buffer_ptr, int buffer_len, rc4_key *key)
{
unsigned char t;
unsigned char x;
unsigned char y;
unsigned char* state;
unsigned char xorIndex;
short counter;

x = key->x;
y = key->y;
state = &key->state[0];
for(counter = 0; counter < buffer_len; counter++)
{
x = (x + 1) % 256;
y = (state[x] + y) % 256;
swap_byte(&state[x], &state[y]);
xorIndex = (state[x] + state[y]) % 256;
buffer_ptr[counter] ^= state[xorIndex];
}
key->x = x;
key->y = y;
}

int main(int argc, char* argv[])
{
char seed[256];
char data[512];
char buf[buf_size];
char digit[5];
int hex, rd,i;
int n;
rc4_key key;

if (argc < 2)
{
fprintf(stderr,"%s key out\n",argv[0]);
exit(1);
}
strncpy(data, argv[1], sizeof(data));
data[sizeof(data) - 1] = '\0';
n = strlen(data);
if (n&1)
{
strcat(data,"0");
n++;
}
n/=2;
strcpy(digit,"AA");
digit[4]='\0';
for (i=0;i0)
{
rc4(buf,rd,&key);
fwrite(buf,1,rd,stdout);
rd = fread(buf,1,buf_size,stdin);
}
}
================================================================================

_________________
Успехов!
#2

subj