Paste #430769

Welcome On LodgeIt

Welcome to the LodgeIt pastebin. In order to use the notification feature a 31 day cookie with an unique ID was created for you. The lodgeit database does not store any information about you, it's just used for an advanced pastebin experience :-). Read more on the about lodgeit page. Have fun :-)

hide this notification

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python

import telnetlib
import sys
import cgi

form=cgi.FieldStorage()
#print "Content-Type: text/html\n"

if form.has_key('external'):
	url_external = form['external'].value
else:
	url_external = "false"


if form.has_key('thenumber'):
	url_number = form['thenumber'].value
	if form.has_key('from'):
		url_extension = form['from'].value
		if form.has_key('name'):
			url_name = form['name'].value
		else:
			url_name = "unknown"

		HOST = "asterisk"
		PORT = "5038"
		USERNAME = "asdf"
		PASSWORD = "foo"

		tn = telnetlib.Telnet(HOST,PORT)
		tn.read_until("Asterisk Call Manager/1.1")
		tn.write("Action: Login\n")
		tn.write("Username: %s\n" % USERNAME)
		tn.write("Secret: %s\n" % PASSWORD)
		tn.write("\n")
		tn.write("Action: Originate\n")
		if url_external != "false":
			tn.write("Channel: SIP/SIL/+%s\n" % url_external[1:])
		else:
			tn.write("Channel: SIP/%s\n" % url_extension)
		tn.write('CallerID: <%s>\n' % url_extension)
		tn.write("MaxRetries: 1\n")
		tn.write("RetryTime: 60\n")
		tn.write("WaitTime: 0\n")
		tn.write("Context: from-internal\n")
		tn.write("Exten: +%s\n" % url_number[1:])
		tn.write("Priority: 1\n")
		tn.write("\n")

if url_external != "false":
	print "Content-type: image/png\n"
	print file(r"/var/www/cgi-bin/mobile_icon.png", "rb").read()
else:
	print "Content-type: image/gif\n"
	print file(r"/var/www/cgi-bin/phone_icon.gif", "rb").read()