Skip to content

Instantly share code, notes, and snippets.

@Kodiologist
Created November 22, 2016 21:21
Show Gist options
  • Save Kodiologist/0c32a32577c150bd486d48f4350d11e0 to your computer and use it in GitHub Desktop.
Save Kodiologist/0c32a32577c150bd486d48f4350d11e0 to your computer and use it in GitHub Desktop.
Citibank.com scraping: XYZ_Extra, XXX_Extra
# Compute the values of the extra fields XXX_Extra and
# XYZ_Extra. This requires munging some deliberately
# obfuscated code.
#
# Sometimes XXX_Extra and XYZ_Extra aren't provided (hence the
# "if"), in which case we don't need them.
my %extra_fields;
if ($body =~ m{
<script \s type="text/javascript"> \x0d \x0a
(function .+?)
\x0a \x0a \x0d}xs)
{msg 'Found script.';
my @funs = split /\n/, $1;
# There should be exactly 4 of these functions, or
# something has changed server-side.
@funs == 4 or die 'numcheck';
my $fun = runsub
{foreach (@funs)
{/(\w+)='<input type="hidden"/ or die;
my $varname = $1;
/\.append\($varname\)/ or next;
return $_;}
die 'No active fun found';};
$fun =~ /'([^']+)';if\([^)]+\).+?'(\d+)'/ or die;
my ($initial, $offset) = ($1, $2);
%extra_fields =
(XYZ_Extra => $fun =~ /name=XYZ_Extra value=([^>]+)/,
XXX_Extra => substr $initial, length($initial) - $offset);}
else
{msg 'No script.';}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment