Using Binary Search To Find Hikmah User Count

Introduction

In this blog article I want to share an interesting use case of binary search. Finding hidden information from a website. The method shown here will work in many other areas – I will leave that to the reader.

We are going to use the concept of binary search to find out how many users are registered in the new social media, hikmah. This information is not available to the general users.

Binary search is a quick way to find something in a sorted list. Instead of checking items one by one, it looks at the middle item first. If that’s not the right one, it decides whether to keep searching in the top half or the bottom half, cutting the list in half each time. This makes the search much faster.

Binary Search - By Mazen Embaby - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=124018514

What is Hikmah

Hikmah.net is a social media platform where you can connect with others in a space built on respect and good values. There’s no corporate censorship, no addictive algorithms, and no indecent content — just healthy, mindful digital habits.

hikmah public frontend

It is built by an amazing company called Kahf.

kahf.com.tr homepage screenshot

Process

Step 01

We need to create a free hikmah account and open the website using firefox.

Step 02

Now Right-click > Inspect. Then open the network tab.

Step 03

Follow any user and see the POST request sent by the browser. Right click on the request and click Edit and Resend.

For the technical readers, here is the cURL version of the follow request:

curl 'https://hikmah.net/api/follow/user/store' \
  --compressed \
  -X POST \
  -H 'Accept: application/json' \
  -H 'Cookie: <auth cookies here>' \
  --data-raw '{"id":172918,"action":"follow"}'

…and here is the response body:

{"data":"Ok"}

Step 04

Now, notice that the ID of the user we followed is 172918. Let’s try to edit the ID and follow another user with a bigger ID, like 200000.

It seems like there is no user with the ID 200000. But there is an user with the ID 172918. Now we need to try a number between this range.

Step 05

Let’s send the same request using the ID 185000.

Still does not exist. Let’s try a smaller number than 185000, but larger than 172918. How about 175000?

It works, Alhamdulillah!

Step 06

Now we need to keep using the same method to narrow down our range. We need to try 5-10 more times to locate the exact number.

At the time of writing this article hikmah has a total of 175,960 registered users.

Read the recent articles

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *