/AboutIP /ClientPOE /ClientPerl /ClientQt /Clients /History /News /Protocol /SampleCode /Tools /Who |
- authtoken from html-source
- decodeCookie
- getAuthToken.sh
- getAuthToken.pl
- GetAuthToken.mrc
- QT/C++ code
authtoken from html-source
The quickest way to get your authtoken:
open a chat in a new tab/window, for example #damnhack
view the html source and search for this line: initdAmnChat("chat.deviantart.com", "chat:somechat", "your_username", "here_is_your_authtoken");
decodeCookie
To decode your cookie, you can use this online urldecoder.
getAuthToken.sh
Here's the bash/wget/grep/sed way to get your authtoken. Should work in all unix/linux/cygwin environments.
#!/bin/bash
# (c) copyright 2006 Bernd Zeimetz (bzed)
# <URL:http://www.moeffju.net/w/dAmn/moin.cgi/dAmn/Tools> for details
#
# This code is released under the GNU General Public License.
# See http://www.gnu.org/copyleft/gpl.html for details
echo -n 'enter username: '
read user
echo "."
echo -n 'enter password: '
read pass
echo "."
wget -q -O - --user-agent="Mozilla" --post-data="action=Back to deviantART&username=${user}&password=${pass}&reusetoken=1&ref=http://chat.deviantart.com/chat/damnhack" http://www.deviantart.com/users/login | \
grep "initdAmnChat" | \
tail -n 1 |\
sed 's/.*, "//g;s,".*,,g'
getAuthToken.pl
This is the perl way to get your authtoken. Please note the token changes with every logout/login. This script will reuse existing tokens and will not log you out of dA.
If you give user/pass on the command line, it will just return the authtoken on STDOUT and exit with 0.
If an error occurs, it will print to STDERR and exit with 1.
#!/usr/bin/perl -w
# (c) copyright 2004 Matthias "moeffju" Bauer
# <URL:http://moeffju.net/w/dAmn/moin.cgi> for details
#
# This code is released under the GNU General Public License.
# See http://www.gnu.org/copyleft/gpl.html for details
use strict;
use warnings;
use IO::Socket::INET;
my $debug = 0; # Change to 1 to enable debugging.
my ($authtoken, $username, $password, $interactive);
if ($#ARGV == 1) {
$interactive = 0;
($username, $password) = @ARGV;
} else {
$interactive = 1;
print "Please enter your deviantART username and password.\n";
print "Username: ";
chomp($username = <STDIN>);
system "stty -echo";
print "Password: ";
chomp($password = <STDIN>);
print "\n";
system "stty echo";
}
die "Username and password must be given" unless $username and $password;
my $socket = IO::Socket::INET->new (
PeerAddr => 'www.deviantart.com',
PeerPort => 80,
Proto => 'tcp')
or die "Unable to open socket: $!";
my $payload = "username=${username}&password=${password}&reusetoken=1";
my $l = length($payload);
my $packet = qq(POST /users/login HTTP/1.1
Host: www.deviantart.com
User-Agent: getauth.pl/0.1
Accept: text/html
Cookie: skipintro=1
Content-Type: application/x-www-form-urlencoded
Content-Length: ${l}
${payload});
debug($packet);
print $socket $packet;
while (defined (my $line = <$socket>)) {
debug($line);
if ($line =~ m/^Set-Cookie: /) {
my ($userinfo) = ($line =~ m/\b(userinfo=[^\s]+)\b/);
$userinfo =~ s/\+/ /g;
$userinfo =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("c",hex($1))/eg;
debug($userinfo);
($authtoken) = ($userinfo =~ m/"authtoken";s:32:"([0-9a-f]{32})";/);
debug($authtoken);
}
}
print STDERR "Error: $!\n" if $!;
if ($authtoken) {
if ($interactive) {
print "Your auth token is: ${authtoken}\n";
} else {
print $authtoken;
}
exit(0);
} else {
print STDERR <<_EOF_;
Error fetching auth token - make sure you entered the correct user/pass.
The script probably does not work behind a proxy - get the authtoken
directly from your stored Cookies.
See <URL:http://moeffju.net/w/dAmn/moin.cgi> for details.
_EOF_
exit(1);
}
sub debug {
if ($debug and $_[0]) {
chomp($_[0]);
print STDERR "[debug] $_[0]\n";
}
}
GetAuthToken.mrc
/authtoken enter your username in the left box and your password in the right one
This is how you can get your authtoken using mIRC. Please note the token changes with every logout/login. This script will reuse existing tokens and will not log you out of dA. Original code: Matthias "moeffju" Bauer Mirc translated code: Christophe "`rnx" tardif
dialog getauthtoken {
title "GetAuthToken.mrc"
size -1 -1 194 26
option dbu
edit "Username", 1, 1 4 79 10
edit "Password", 2, 83 4 86 10, pass
edit "", 3, 1 15 168 10, read
button "Get", 4, 169 4 24 21
}
alias authtoken {
dialog -dm getauthtoken getauthtoken
}
alias getauthtokenwrite {
sockwrite -n getauthtoken $1-
}
on *:dialog:getauthtoken:sclick:4:{
if ($did(getauthtoken,1) == username) { halt }
if ($did(getauthtoken,1) == $null) { halt }
if ($did(getauthtoken,2) == password) { halt }
if ($did(getauthtoken,2) == $null) { halt }
unset %authtoken
did -o getauthtoken 3 1 Connecting...
%danickname = $did(getauthtoken,1)
%dapass = $did(getauthtoken,2)
sockclose getauthtoken
sockopen getauthtoken www.deviantart.com 80
}
on *:sockopen:getauthtoken:{
if ($sockerr > 0) { did -o getauthtoken 3 1 error }
%payload = username= $+ %danickname $+ $chr(38) $+ password= $+ %dapass $+ $chr(38) $+ reusetoken=1
%1 = $len(%payload)
getauthtokenwrite POST /users/login HTTP/1.1
getauthtokenwrite Host: www.deviantart.com
getauthtokenwrite User-Agent: getauth.mrc/0.1
getauthtokenwrite Accept: text/html
getauthtokenwrite Cookie: skipintro=1
getauthtokenwrite Content-Type: application/x-www-form-urlencoded
getauthtokenwrite Content-Length: %1
getauthtokenwrite $lf
getauthtokenwrite %payload
did -o getauthtoken 3 1 Sending HTTP header...
}
on *:sockread:getauthtoken:{
sockread %a
if (authtoken isin %a) {
%a = $right(%a,$calc($len(%a) - 21))
%a = $left(%a,$calc($pos(%a,;) - 1))
%data = $replace(%a,$chr(37) $+ 3A,:,$chr(37) $+ 7b,$chr(123),$chr(37) $+ 22,$chr(34),$chr(37) $+ 3b,$chr(59),$chr(37) $+ 7D,$chr(125))
%filter = a:6:{s:8:"uniqueid";s:32:"£uniqueid£";s:10:"visitcount";i:£visitcount£;s:9:"visittime";i:£visittime£;s:10:"firstvisit";i:£firstvisit£;s:8:"username";s:3:"£username£";s:9:"authtoken";s:32:"£authtoken£";}
if ($parse = done) && (%authtoken != $null) {
;did -o getauthtoken 3 1 Token: %authtoken
%pk = %authtoken
}
unset %a
}
}
on *:sockclose:getauthtoken:{
did -c getauthtoken 2
unset %dapass
if (%authtoken != $null) {
did -o getauthtoken 3 1 Token: %authtoken
}
else {
did -o getauthtoken 3 1 E: make sure you entered correct username/passwd
}
}
QT/C++ code
is included in KDeviant (dAmn/ClientQt). Take a look at getauth.{h, cpp}