File: linuxtrade.auth

package info (click to toggle)
linuxtrade 3.65-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,880 kB
  • ctags: 1,969
  • sloc: ansic: 30,091; sh: 2,278; perl: 566; makefile: 126
file content (290 lines) | stat: -rwxr-xr-x 7,615 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/sh

#
#	Handle simple authorization tasks
#
#	Given a username and password on stdin, print the
#	authorization code (a.k.a. hashed password)
#
getval() {
    # <INPUT TYPE=hidden NAME="DV_DATA" VALUE="1050156126739">
    what=$1
    where=$2
    eval $what=`sed -n "s/^.*\"$what\" *VALUE=\"\([^\"]*\)\".*/\1/p" < $where`
}

UA="Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"
LT=$HOME/.linuxtrade

case "$1" in
moneyam.com)
	read username
	read password
	URL="https://www.moneyam.com/action/user/processLogin"
	curl -A "$UA" -s \
	    -D- \
	    -d action=login \
	    -d username=$username \
	    -d password=$password \
	    -d saveDetails=on \
	    -o/dev/null $URL \
	    | sed -n 's/Set-Cookie: JSESSIONID=\([^;]*\).*/\1/p'
	;;

esignal.com)
	read username
	read password
	URL="http://mc.esignal.com/mcAuth.asp"
	PAGE=$LT/esignal.page
	# Authentication is fruity with this streamer.  It can take up
	# to 3 tries to get a valid key *and* a valid IP address.
	for i in 1 2 3 4; do
	    curl -L -A "$UA" -s \
		"-duser=$username" \
		"-dpassword=$password" \
		"-dsubmit=GO" \
		$URL > $PAGE
	    # cp $PAGE /tmp/$i
	    key=`sed -n 's/^.*&key=\([^&"'"'"']*\).*/\1/p' < $PAGE`
	    host=`sed -n 's/^.*&host=\([^&"'"'"']*\).*/\1/p' < $PAGE`
	    case "$host" in
	    "")
		    if [ "$key" != "" ]; then
			echo "$key";
			echo "mc.esignal.com";
			exit 0;
		    fi
		    ;;
	    *)
		    if [ "$key" != "" ]; then
			echo "$key";
			echo "$host";
			exit 0;
		    fi
		    ;;
	    esac
	    ecode=`sed -n 's/^.*&ecode=\([^&"]*\).*/\1/p' < $PAGE`
	    if [ "$ecode" != "" ]; then
		: #break;
	    fi
	    sleep 1
	done
	echo "invalid-password"
	echo "invalid-host"
	;;

old.money.net)
	read username
	read password
	URL="http://www.money.net/members/login.php"
	URL="$URL?username=$username"
	URL="$URL&password=$password"
	curl -A "$UA" -s -D- -o/dev/null $URL \
		| sed -n 's/Set-Cookie: id=\([^;]*\).*/\1/p'
	echo "invalid password"
	;;

money.net)
	read username
	read password
	URL="http://www.money.net/members/login.php"
	curl -A "$UA" -s \
		-d"username=$username" \
		-d"password=$password" \
		-D- -o/dev/null $URL \
		| sed -n 's/Set-Cookie: id_verified=\([^;]*\).*/\1/p'
	echo "invalid password"
	;;

datek.com)
	read username
	read password
	# URL="https://investment.datek.com/streamer/gostreamer.htm"
	URL="https://investment.datek.com/datek/"
	curl -A "$UA" -s \
		-d ssymbol= -d streamer=streamerLoader -d "__chx=WLOGIN  " \
		-u "$username:$password" \
		"$URL" \
		| sed -n -e 's/.*var paramP = "\(.*\)";.*$/\1/p'
	echo "invalid password"
	;;

ameritrade.com|freetrade.com)
	case "$1" in
	a*)
	    short=amer
	    SHORT=AMER
	    site=wwws.ameritrade.com
	    ;;
	f*)
	    short=free
	    SHORT=FREE
	    site=wwws.freetrade.com
	    ;;
	esac
	read username
	read password
	COOKIES=$LT/$short.cookies
	PAGE=$LT/$short.page
	rm -f $COOKIES

	# Pull up login page
	curl -A "$UA" -s -c $COOKIES \
	    https://$site/apps/LogIn/ > $PAGE.1
	getval DV_DATA $PAGE.1

	# Login and get main page
	curl -A "$UA" -s -b $COOKIES -c $COOKIES \
	    -d "pagehandler=PHLogIn" \
	    -d "USERGROUP=ACCT" \
	    -d "USERID=$username" \
	    -d "DV_DATA=$DV_DATA" \
	    -d "PASSWORD=$password" \
	    -d "logon=Login Now" \
	    -d "COMPANY=$SHORT" \
	    https://$site/cgi-bin/apps/LogInMain \
	    > $PAGE.2

	# Pull up streamer console page
	curl -A "$UA" -s -b $COOKIES -c $COOKIES \
	    https://$site/cgi-bin/apps/LaunchStreamerConsole \
	    > $PAGE.3

	# Extract authentication data from console page
	getval token $PAGE.3
	getval timestamp $PAGE.3
	getval cddomain $PAGE.3
	getval acl $PAGE.3
	echo $token $timestamp $cddomain $acl
	;;

prophet.net)
	read username
	read password
	COOKIES=$LT/pf.cookies
	curl -L -A "$UA" -s \
	    -c $COOKIES \
	    -d "username=$username" \
	    -d "password=$password" \
	    -d "login=Sign+In" \
	    http://www.prophet.net/forms/signin.jsp \
	    > /dev/null
	echo $COOKIES
	;;

p*|prophetfinance.com)
	read username
	read password
	USERNAME=`echo "$username" | tr '[a-z]' '[A-Z]' `
	COOKIES=$LT/pf.cookies
	curl -A "$UA" -s \
		-d "path=/Default.asp" \
		-d "pagequery=1|eq|1" \
		-d "UserName=$username" \
		-d "PassWord=$password" \
		-d "Login=Login" \
		-D $COOKIES \
		https://www.prophetfinance.com/forms/login.asp \
		> /dev/null

	curl -s -b $COOKIES \
		"http://www.prophetfinance.com/servlet/ConfigServer?cmd=config.get&product=JC&hostname=www.prophetfinance.com&userrights=In,Mu,St&username=$USERNAME&stockWizard=1&cachekey=391859796926765888" |
		sed -n '/authkey/s/.*|\(.*\)/\1/p'

	;;

quote.com|livecharts.com|lycos.com)
	#
	#	Get the encoded form of the password, for use in grabbing
	#	charts.  Output the encrypted password as well as the
	#	filename of the applet page.
	#
	read username
	read password
	LOCATION=$LT/lc.location
	COOKIES=$LT/lc.cookies
	PAGE=$LT/lc.page
	> $COOKIES
	#
	# Authorize, following Location: redirects until we have collected
	# all of the cookies.  I think there are 3 redirects in total.
	#
	curl -A "$UA" -s -o$PAGE \
                -d "m_PR=4" \
                -d "m_CBURL=http://finance.lycos.com/Default.asp?symbols=" \
                -d "m_CBERRURL=http://finance.lycos.com/Default.asp?symbols=" \
                -d "m_HOSTURL=" \
                -d "m_TRURL=" \
                -d "Z=`date +%s`" \
                -d "m_LANG=1" \
                -d "m_BDATA=" \
                -d "m_DL_FREE=1" \
                -d "m_U=$username" \
                -d "m_P=$password" \
                -d "m_AS=1" \
                -d "m_WS=on" \
                -D $LOCATION \
		-c $COOKIES -L \
                http://ldbauth.lycos.com/cgi-bin/mayaLogin

	#
	# Now fetch the page with the applet, and snarf the password
	#
	curl -L -A "$UA" -s -o$PAGE -b$COOKIES -c$COOKIES \
		"http://finance.lycos.com/home/livecharts/body.asp"
	sed -n '/<param name="Pswd" value="/s/.*="\(.*\)".*/\1/p' <$PAGE
	echo $PAGE
	;;

yahoo.com)
	COOKIES=$LT/yahoo.cookies
	LOGINHTML=$LT/yahoologin.html

	#get the initial login page
	URL="http://login.yahoo.com/config/login"
	URL="$URL?.src=quote&.intl=us"
	URL="$URL&.done=http://finance.yahoo.com/?u"
	curl -A "$UA" -c $COOKIES -s -L "$URL" > $LOGINHTML

	#pull out the form values needed to login
	UVAL=`grep -i "\"\.u\"" $LOGINHTML |
		sed -e 's/^.*value="//' -e 's/".*//'`
	CHALLENGE=`grep -i "name=\"\.challenge\"" $LOGINHTML |
		sed -e 's/^.*value="//' -e 's/".*//'`

	read username
	read password

	URL="http://login.yahoo.com/config/login"
	URL="$URL?.tries=&.src=ym&.last=&promo=&.intl=us"
	URL="$URL&.bypass=&.partner="
	URL="$URL&.u=${UVAL}&.v=0&.challenge=${CHALLENGE}"
	URL="$URL&.emailCode=&hasMsgr=1&.chkP=Y&.done="
	URL="$URL&login=${username}&passwd=${password}"
	URL="$URL&.persistent=&.save=1&.hash=0&.js=0&.md5=0"
	curl -A "$UA" -b "$COOKIES" -c $COOKIES -s -L "$URL" > /dev/null
	# Netscape HTTP Cookie File
	# http://www.netscape.com/newsref/std/cookie_spec.html
	# This file was generated by libcurl! Edit at your own risk.

	#.yahoo.com	TRUE	/	FALSE	1271361600	B	espjofoubfq9p&b=2
	#.yahoo.com	TRUE	/	FALSE	0	Y	v=1&n=1d18rptjs34te&l=b8dknjh034/o&p=m1p1m2vc01000300&r=9d&lg=us&intl=us&np=1
	#.yahoo.com	TRUE	/	FALSE	0	T	z=8k.t8A8qTu8AU0yLN4ezM5M&a=QAE&sk=DAAxT4Xsgbj6e7&d=YQFRQUUBdGYBQkFBAXp6AThrLnQ4QWdXQQ--&af=QStBQmdBJnRzPTEwMTg2ODU3NTYmcHM9dEw1N19wZzZKcXQ1RzBsX2FxRzdpUS0t
	#.yahoo.com	TRUE	/	FALSE	1271361600	C	mg=1
	cookies=
	while read site flag1 path flag2 time name val
	do
		case "$site" in
		"#"*)	continue;;
		"")	continue;;
		esac
		cookies="$cookies $name=$val;"
	done < $COOKIES
	echo "$cookies"
	
	;;

*)
	echo "unknown streamer"
	;;
esac