Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

If you're new here please read PerlMonks FAQ
and Create a new user.

poll ideas quest 2022
Starts at: Jan 01, 2022 at 00:00
Ends at: Dec 31, 2022 at 23:59
Current Status: Active
6 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
PDL 2.081 released
on Oct 26, 2022 at 17:35
1 reply by etj
    PDL 2.081 has just been released. Notable changes since 2.079:
    • Most of PDL::VectorValued has now been incorporated into PDL::Primitive
    • Bugfixes including the t_rot one in 683514, and to MatrixOps::inv, conv2d and MatrixOps::identity
    • inflateN added
    • allow [o] on OtherPars, which helps towards PDL::OpenCV

    The IRC channel (#pdl on is a great virtual place to come and ask questions, or just watch the GitHub messages flow by.

    Please give the new PDL a try and report problems.

YAPC::Europe/PerlCon/KohaCon 2023-08-14..18 announcement
on Oct 18, 2022 at 16:13
0 replies by Corion
Access and decrypt Chrome cookies on Windows
2 direct replies — Read more / Contribute
by Discipulus
on Nov 30, 2022 at 03:45
    Hello folks,

    Christmas approaches and raises my will to open cookies jars.. :)

    If I just modify the path and the table name in this program to access Chrome 107 cookies ('C:/Users/'.$ENV{UserName}.'/AppData/Local/Google/Chrome/User Data/Default/Network/Cookies'; the path and cookies the table) I get a nice screenful of... encrypted cookies.

    To offer encrypted cookies is against the Halloween trick or treat policy: is both trick and treat in the same time!

    I read here:

    > Since Chrome version 80 and higher, cookies are encrypted using AES-256 in GCM mode. The applied key is encrypted using DPAPI. (...) The encrypted key starts with the ASCII encoding of DPAPI (i.e. 0x4450415049) and is Base64 encoded, i.e. the key must first be Base64 decoded and the first 5 bytes must be removed. Afterwards a decryption with win32crypt.CryptUnprotectData is possible. The decryption returns a tuple whose second value contains the decrypted key:

    From what I understand there is key and this key is used to enrypt the encrypted_value inside the cookies DB. Too much for me..

    So again on metacpan for HTTP::Cookies::Chrome that installs fine under windows. The load_cookies.t sounds promising but fails, because guess_password method is unimplemented for Windows. Meh!

    This perl gist (probably by PerlRob)

    seems to be the solution, calling the native Windows CryptUnprotectData API but fails with Win32::API::Call: parameter 7 had a buffer overflow

    Porting to Perl the code presented here or here and then patching the HTTP::Cookies::Chrome module?

    Why this? I'm not so gluttonous, but I suppose that accessing a real cookie is key point in web automation: if I'm able to present the right session cookie my program is me.

    Thanks for reading!


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Malformed UTF-8 character
3 direct replies — Read more / Contribute
by BillKSmith
on Nov 29, 2022 at 15:53
    I know that this question is slightly off-topic, but still seems relevant. I am unable to download and run 1nickt's solution Re: Regex: matching any Number then a hyphen to a recent question because of a single non-ascii character. While displaying the node in the browser 'Chrome' on Windows 7, I click on the 'download' button. The file displays correctly. I right-click and select 'save as' then save as When I run the file, I get the following error:
    C:\Users\Bill\forums\monks>perl 1..3 Malformed UTF-8 character: \x96 (unexpected continuation byte 0x96, wi +th no prec eding start byte) at line 9. Malformed UTF-8 character (fatal) at line 9.
    Using Internet explorer is slightly different, but no better. I have also tried cut-and-paste into the editor 'gvim'. It does not even display correctly. No luck saving it to a file. What is the recommended way to download and edit files containing UTF-8 characters from perlmonks into windows?

    Sorry if I have overlooked the tutorial that I need.

DBI DBD::SQLite unable to open Firefox cookies.sqlite database
3 direct replies — Read more / Contribute
by Discipulus
on Nov 29, 2022 at 06:39

    inspired by Using LWP (or some other module) to Dowload HTML with Cookie Session ID I tried to unlock the cookies case of Firefox using perl. I have installed DBD::SQLite but the following code fails to open the DB even if Firefox is closed or if try the readonly flag.

    I also tried to make a copy of the DB cookiesTEST.sqlite in the case some lock was there.. but nothing but failures.

    use strict; use warnings; use Data::Dumper; use DBI; use DBD::SQLite; my $db = $ENV{AppData}.'\Mozilla\Firefox\Profiles\nwk2oixj.default-rel +ease\cookiesTEST.sqlite'; die "DB file not found!" unless -e $db; print "sqlite DBD version: $DBD::SQLite::sqlite_version\n"; my $dbh = DBI->connect(qq(dbi:SQLite:dbname=$db,'','',{ sqlite_open_flags => SQLITE_OPEN_READONLY, PrintError => 1, RaiseError => 1, })) or die $DBI::errstr; my $sth = $dbh->prepare(q(SELECT * FROM moz_cookies )); print Dumper $sth->fetchall_arrayref({}); __END__ sqlite DBD version: 3.39.4 DBI connect('dbname=C:\Users\ME\AppData\Roaming\Mozilla\Firefox\Profil +es\nwk2oixj.default-release\cookiesTEST.sqlite,'','',{ sqlite_open_flags => SQLITE_OPEN_REA +DONLY, PrintError => 1, RaiseError => 1, }','',...) failed: unable to open dat +abase file at line 11. unable to open database file at line 11.

    With FF open both DBeaver and sqlite3 command line utility can access the DB without problem. DBeaver uses jdbc:sqlite driver and sqlite> .version shows SQLite 3.40.0 2022-11-16 12:10:08 so not the 3.39.4 shown by DBD.

    I have no sqlite in the path.

    Searching I found HTTP::Cookies::Mozilla and I installed it: it comes with a stringy documentation ( yes! adopt it ;) but, lurking in /examples I have found /examples/ that slightly modified to work on windows (around line 19 my @cookies_files = glob(     $ENV{AppData}.'\Mozilla\Firefox\Profiles\*\cookies.sqlite'); ) accesses the db without any issue.

    The module documentation ( scan method not even mentioned ;) says explicitly:

    > .. so you will need to have either DBI/DBD::SQLite, or the sqlite3 executable somewhere in the path.

    Since I have not sqlite in the path, it should use the very same driver used by my failing script, ie: DBD::SQLite

    So why the above code fails?


    PS ..and now crack the Chrome cookies jar

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
WWW::Mechanize::Chrome VERY slow on xpath obtaining TDs of a TR
3 direct replies — Read more / Contribute
by ait
on Nov 25, 2022 at 07:43

    Hello ye monks!

    UPDATE: the time seems to be proportional to the number of rows. The 2-3 second timing is for a table with 450 rows and 12 columns.
    On a table with 120 rows, it's less than a second. Speculating: it would seem that relative to node xpath has some bug and may be scanning the whole table each time.

    Anybody out there have any clue why this takes 2 to 3 seconds:

    my @cells = $mech->xpath('.//td', node => $rows[$row_index]);

    Posted the issue here.
    I posted the issue here:

    But answers and wisdom usually come faster in the Monastery ;-)

    If anyone knows a cheaper way to get the TDs of a TD using WWW::Mechanize::Chrome or have any other suggestion pls. do tell !



PerlMonks Discussions
Recently Active Threads: limited maximum node depth
2 direct replies — Read more / Contribute
by kcott
on Nov 27, 2022 at 17:24

    G'day All,

    This morning, I saw in "Best Nodes" a link to "Re^12: Perl XS binding to a struct with an array of chars*". I looked in RAT to get an idea of the activity in this thread: there were a number at "Re^9" but nothing deeper. I went to the Page Settings (bottom of the RAT page) to change the maximum depth but the selection only provides 0-10.

    Scrolling through (the very long) "Perl XS binding to a struct with an array of chars*", I found a couple at "Re^10" as well as the "Re^12" (from Best Nodes). So, I haven't lost access to any content; however, it would've been preferable to get a high-level view via RAT.

    Can that "maximum depth" selection be extended? I don't know if there are other factors involved, so I don't know what to suggest beyond arbitrary ranges such as 0-20 or 0-99. Alternatively, could there be a "no depth limit" checkbox? I imagine a text entry box would be another option, but I suspect that might require a fair bit of validation and other work which pmdev's may not want to undertake (although, I'm very much guessing about that).

    — Ken

Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2022-11-30 14:27 GMT
Find Nodes?
    Voting Booth?