Skip to content

File write on PostgreSQL 9.1.15 fails #1170

Closed

Description

@bdamele

File write operations (hence takeover) fails on PostgreSQL 9.1.5 with an error on lo_export():

[20:47:01] [PAYLOAD] 1;SELECT lo_export(2008, '/tmp/test123.txt')--
[20:47:01] [WARNING] parsed DBMS error message: 'ERROR:  pg_largeobject entry for OID 2008, page 0 has invalid data field size 2378'

This happens also if connected as postgres with psql to the database locally. Same statements worked on PostgreSQL 9.1.11.

Check documentation on http://www.postgresql.org/docs/9.1/static/catalog-pg-largeobject.html.

Activity

  1. self-assigned this
    on Feb 20, 2015
  2. added this to the 1.0 milestone on Feb 20, 2015
  3. RicterZ commented on Jun 2, 2015

    @RicterZ
    Contributor

    Hello, I read the document and found:

     The amount of data per page is defined to be LOBLKSIZE (which is currently BLCKSZ/4, or typically 2 kB).
    

    It means that every block of the data inserted into pg_largeobject less than 2kb.
    So, I think you should split the data:

     SELECT lo_create(12345);
     INSERT INTO pg_largeobject VALUES (12345, 0, decode('7f454c4...0000', 'hex')); //less than 2kb
     INSERT INTO pg_largeobject VALUES (12345, 1, decode('0000000...0000', 'hex'));  //less than 2kb
     INSERT INTO pg_largeobject VALUES (12345, 2, decode('f604000...0000', 'hex')); //less than 2kb
     INSERT INTO pg_largeobject VALUES (12345, 3, decode('0000000...7400', 'hex')); //less than 2kb
     SELECT lo_export(12345, '/tmp/test.so');
     SELECT lo_unlink(12345);
    
  4. bdamele commented on Jun 4, 2015

    @bdamele
    MemberAuthor

    @RicterZ thanks for trouble-shooting this.

  5. stamparm commented on Jul 21, 2015

    @stamparm
    Member

    Will deal with it these days
    On Jul 21, 2015 9:07 PM, "Kamulha" notifications@github.com wrote:

    Hi!
    I encountered this problem with PostgreSQL 9.1.16 and 9.1.18 (64 bit).
    The strange thing is that SQLMap doesn't output any problem, it says the
    right file size on the server (8136 bytes).
    But obliviously nothing is working, --os-shell gives no output and
    --os-pwn encounters a timeout with all of the available options.
    Are you going to fix this soon?
    Thanks in advance.
    Kamulha

    —
    Reply to this email directly or view it on GitHub
    #1170 (comment)
    .

  6. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    Couple of related screenshots:

    1
    2
    3
    4
    5
    6

  7. RicterZ commented on Jul 24, 2015

    @RicterZ
    Contributor

    👍

  8. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    still have some stuff to do :)

  9. added a commit that references this issue on Jul 24, 2015
  10. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    Now it should work on both PostgreSQL 8 and >=9 ;)

  11. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    @Kamulha Maybe you'll have problems with WRITE permissions, but that's maybe.

    Combination of https://raw.githubusercontent.com/sqlmapproject/testenv/master/libs/pgsql.inc.php and https://raw.githubusercontent.com/sqlmapproject/testenv/master/pgsql/get_int.php should suffice. You'll have to modify them though (username, password, ...).

  12. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    @Kamulha no. pgsql.inc.php also contains function dbQuery. Concatenate those two files (get_int.php and pgsql.inc.php), modify settings (username, password, port, etc.) and upload them as one file.

  13. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    file size check is broken. its independent of this issue. will check later.

    p.s. current implementation just checks whether the "supporting" table(s) have been filled as they should.

  14. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    I am not sure if I follow. Can you please explain what you meant with this last message?

  15. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    I would say that you have write permission problems. Have you tried to write to e.g. directory /tmp. I've warned you about this

  16. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    table "sqlmapfile" does not exist is a standard error. Its just cleaning (if exists) the old table

  17. stamparm commented on Jul 24, 2015

    @stamparm
    Member

    @Kamulha this really doesn't look like a generic case. Not sure how to help you here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions