Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
User Posts

Go to Profile

BT v1/v2 parser Work — 2022-02-14 03:28:01 in M-BiTsy Support
Okay uploading works perfectly. What I made the mistake with, was:

Bencode::encode($torrentInfo) - Wrong! It has no clue what to do, and does its best with the array it see's.

We use the class to read the key values to assist in field population in torrent table (name, hash, size, etc)

Now when actually saving the .torrent to file, we must do this:

TorrentTrader - put_file_contents('uploads/somename.torrent', file_get_contents($_FILES['torrent']['tmp_name']))
BLOB Field - get_file_contents($_FILES['torrent']['tmp_name'])

Replace somename.torrent with $_POST['name'] for example - the form torrent name field.

Now its working perfectly. All data shows up in my index and provides the exact results I expected. Lesson learned here lol
Great! Yah just remember, PDO is faster and much more secure reducing a lot of code required to make secure with the MySQLi module, but it is safe enough to use as it is actively maintained and released.

For this case, we are just working with GET requests and reading/writing to the peers/torrent table and returning that back to the bittorrent client of your choice.

Will begin shortly 😉
I’ll fix you up.

Give me a few hours. I have the MySQLi extension so I can have edit my announce request in my client to a test file and confirm peers.
Say Thanks & Force — 2022-02-13 20:07:49 in v3 Mods Completed
I’ll do it. Give me a couple hours this afternoon (my time), and you will have full modification for your desire.
Hey there!

Please describe your TT version, and I can help further.

This announce script was a early release to take users out of the shackles of the old script that was very outdated. I can then help much further.

This needs a major update to reflect new changes in my mainline announce code running live for 43000 people.
BT v1/v2 parser Work — 2022-02-12 19:43:54 in M-BiTsy Support
Track updates here:

https://bit.ly/3GMPh4v
BT v1/v2 parser Work — 2022-02-12 19:41:56 in M-BiTsy Support
Yah its pretty confusing, in my case its reading LONGBLOB so I right click on row and "Save BLOB as file" => .torrent file to desktop and open with uTorrent, but its all wrong all the time. Its a challange for sure! - I have to remind myself to not rely on uTorrent lol

Hybrid - Are we just defaulting to V1 if client does not support? How do we know? I mean, we can create a table of user agents and version and track that will a field describing V1/V2 capabilities (qBittorrent 4.4.4 for example), even dumping the clients from peers table to a new table in cleanup class, but thats a dirty solution - we 'could' decide decoder based on that.  
BT v1/v2 parser Work — 2022-02-12 11:32:01 in M-BiTsy Support
BEP_35 - This extracts the certificate info out of a signed .torrent file, and separates the certificate fields into their own keys to merge into $torrentInfo fast and efficiently - no slow Reggex!

This will pull any info out of the file signed by any certificate authority, for example:
Let's Encrypt, Verisign, ZeroSSL, Cloudflare Origin, etc etc.

This extracts all you need to use and display on torrent pages by getting into the secure RSA-2048 encrypted dictionary.
It was not easy, took me almost 3 hours. You wont find this code anywhere, because it quite simply does not exist.

Proudly coded for the ST Tracker 😉 Enjoy~

I hope we can get past the requirements of the compiled binary and passthru() requirement, and somehow find a way to do this with OpenSSL natively in PHP. Anyway.. in the meantime, I share my work:


$torrentInfo['signed']  = array_key_exists('signatures', $array) ? 'Yes' : 'No';
if (array_key_exists('signatures', $array)) {
   foreach ($array['signatures'] as $value => $key) {
       $torrentInfo['authority'] = $value;
       foreach ($key as $certinfo) {
           $filter                     = array('' => '', '' => '', '' => '', '' => '', '' => '', ' ' => '', '' => '', 'U' => '', '6' => '', '/' => ' ', '0x06' => '', '' => '', '' => '', '1' => '', '8' => '', '0' => '', '' => '', '2' => '', '4' => '', '9' => '', 'Z' => '', '3' => '', 'b' => '');
           $alloc                      = strtr($certinfo, $filter);
           $torrentInfo['certificate'] = explode (' ',  trim(explode("\n", $alloc)[3]), 3)[2];
           $split = explode("\n", $alloc)[3];
           $sep                        = preg_split('/[\s,]+/', $split, 3);
           $torrentInfo['issuer']      = implode(', ', array($sep[0], $sep[1]));
           break;
       }
   }
}


Result:

Array
(
   [announce] => https://domain.com/announce?token=aTRYNWZUZVNwWnl2S2lEa3JaWVJNMGEyNkthWGNCUXRUOFhQZDlMUThacEMycVFZNEtEYmNTdXduYjdYWjBOcg==
   [announce-list] =>
   [creation date] => Wed, 09 Feb 2022 17:39:46 -0800
   [comment] => Yessir - Proudly UP'd
   [name] => Haven Park [NSZ]
   [type] => 1
   [hash] => 744ef0c8087409d6c6948b95cbe75276be86ffb4
   [private] => Yes
   [signed] => Yes
   [authority] => CloudFlare Origin Certificate
   [certificate] => CloudFlare Origin SSL ECC Certificate Authority
   [issuer] => CloudFlare, Inc.
   [files] => Array
       (
           [0] => Array
               (
                   [length] => 120592155
                   [path] => Array
                       (
                           [0] => Haven Park [0100E390155E4000][v0].nsz
                       )

               )

           [1] => Array
               (
                   [length] => 136364215
                   [path] => Array
                       (
                           [0] => Haven Park [0100E390155E4800][v720896].nsz
                       )

               )

       )

   [length] => 256956370
   [ttfilecount] => 2
)
Oh.. and the best case for implementing with logic for number verification

Verification Process:
Mobile Number Input => Query API => Active => INSERT to table => true?: => UPDATE user row field => Close
Mobile Number Input => Query API => Inactive => false?: => Exception => Close
What we do over at ST. I am my own security team, so I wrote this step by step and I code accordingly:

Session Token Verification
Session Anti-Fixation Attack
Log Out Everywhere Feature
AJAX Request Rate Limiting

----

Two Factor Authentication (2FA) - SMS PIN

Action: To make sure the account owner is actually the owner.
Reason: An attacker will not have their physical smartphone to spoof their identity.

Trigger:
[X] Change Password
[X] Delete Account
[X] Login Unsuccessfully (3 failed password attempts)

According to condition:
[X] Email Auth (if phone number NOT verified)
[X] SMS Auth (if phone number verified)

Result:
[X] Change Password
[X] Delete Account
[X] Login Successfully

----

Phone Number Verification

If successful, number is stored in separate table with "verified" field.
If number NOT verified, 2FA SMS verification will NOT be available, and only email will be available for verification by email token link (less secure).

----

Even despite all of this in my account class, there is still a problem:

User guesses password. They login. They see IP, account.. everything. How do we prevent that, while allowing multiple location log ins? This part to me so difficult to understand, and a solution is Fortnight and how they do it. If anyone knows the answer to this specific issue, please PM me asap.
2FA/OPT SMS Auth — 2022-02-10 08:43:50 in Downloads & Updates
I am implementing a free SMS API directly inside my STAccounts class for the first time tonight. The last update was token verification & SMTP API notifications (more than 3 login failures, etc).

I did google search, found them SMS.To as the only service that actually sent a SMS to my iPhone from my cURL test PHP script. All others failed, or cost money or disallowed daytime SMS sending unless "Pro" plan. Wtf?

No one has posted or shared any guide or anything at all on getting it running let alone a PHP class - so I do from scratch.

I figure its time to get with the times and consider security a little more. Tokens are nice, but tell that to the big sites out there.
The point of this is to send a 5-digit numerical PIN to a members smart phone as a SMS message from a page form (or login form), and accept the generated PIN as a return entry to the forms input text field, and doing somethign like string comparison according to (you can store the PIN in a table and remove row after verify), allowing whatever it is you wish to do afterwards once that JSON response comes back as "success".  To me, it makes sense to just add a field in `users` table something like


ALTER TABLE users ADD 2fa_auth  enum('yes','no') NOT NULL;


And check that on site and do whatever if that says "yes" for logged in user (show it in account page or something).

We just verify the element with json_decode($something, true) and read the value. SMS.To returns JSON status response back to browser if the SMS to the members phone number was successful or not.

I wrote this and used the API documentation. This may help someone implement in their own script. I've laid it all out for easy porting. Works fine for me.

Define the constants:

class myClass {
  const DEF_SMS_API_HOST  = 'api.sms.to/sms/send';
  const DEF_SMS_API_KEY   = 'Your_Own_API_Key';
  const DEF_SMS_SENDER_ID = 'SMSto';


Set the constants:

$this->smsApiHost = self::DEF_SMS_API_HOST;
$this->smsApiKey = self::DEF_SMS_API_KEY;
$this->smsSenderId = self::DEF_SMS_SENDER_ID;



public function send_twofactor_sms(string $phonenumber): mixed
{
   $securepin = mt_rand(10000,99999);
   $curl    = curl_init();
   $headers = array(
       "Content-Type: application/json",
       "Accept: application/json",
       "Authorization: Bearer " . $this->smsApiKey
   );
   $params  = array(
       'to' => $phonenumber,
       "bypass_optout" => true,
       'message' => "Your verification PIN is \n" . $securepin,
       'sender_id' => $this->smsSenderId
   );
   curl_setopt_array($curl, array(
       CURLOPT_URL => "https://" . $this->smsApiHost,
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_FAILONERROR => true,
       CURLOPT_ENCODING => "",
       CURLOPT_MAXREDIRS => 10,
       CURLOPT_TIMEOUT => 0,
       CURLOPT_FOLLOWLOCATION => true,
       CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
       CURLOPT_CUSTOMREQUEST => "POST",
       CURLOPT_POSTFIELDS => json_encode($params),
       CURLOPT_HTTPHEADER => $headers
   ));
   $response = curl_exec($curl);
   if (curl_errno($curl)) {
      throw curl_error($curl);
   }
   curl_close($curl);
   return $response;
}


Checking and performing next step

$checkauth = json_decode($response, true);
if ($checkauth[0]["success"] == true) {
    // PIN Verified - Do some SQL/friendly message, etc
}


Response:
{
   "message": "Message is queued for sending! Please check report for update",
   "success": true,
   "message_id": "e7745289-7236-497f-acf2-f9cfd6a86f16"
}

Keep in mind, $securepin is not set because you can do it yourself - this is just to get you started. I use my own way.
It's been in the v4 files since the first posted, check out /site.php - its a treasure trove of neat functions.

Alternatively, you can do this to


function get_time_elapsed($datetime)
{
   return round((((time() - strtotime($datetime)) / 60) / 60) / 24) . ' day(s) ago';
}


Or...


function get_time_elapsed($time)
{
   $time   = time() - $time;
   $time   = ($time < 1) ? 1 : $time;
   $tokens = array(
       31536000 => 'year',
       2592000 => 'month',
       604800 => 'week',
       86400 => 'day',
       3600 => 'hour',
       60 => 'minute',
       1 => 'second'
   );
   foreach ($tokens as $unit => $text) {
       if ($time < $unit)
           continue;
       $numberOfUnits = floor($time / $unit);
       return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : '') . ' ago';
   }
}


etc etc. The one posted, that was from stackoverflow is the best because you get that "Just Now" feature.
BT v1/v2 parser Work — 2022-02-06 11:09:48 in M-BiTsy Support
As far as I can tell, the code should be complete. Confirm with your own torrents. I've established plenty of checks in all different types of scenarios to handle any case, it passed every test.

I want to give a big thank you to @M-Jay for his work on this, and the opportunity for me plug to this in to my own site in a light-weight manner - without the need for heavy third-party libraries. Thanks!! It was fun.

Enjoy. 😉
BT v1/v2 parser Work — 2022-02-06 10:45:50 in M-BiTsy Support
Sorry I didn't see this before the shoutbox posts. Sounds good! Disregard the posts, I see progress
BT v1/v2 parser Work — 2022-02-06 09:00:34 in M-BiTsy Support
Changelog - Feb 11/22:

- Shorter code
- Fixed hash detection using version array check (confirmed - qBittorrent v4.4.0)
- Fixed incorrect count caused by extra padding data
- Reduced long checks with shorter logic
- Correctly check version using 'meta version' tree item (specification)
- Checks correct version for file list iteration to handle all cases
- Replaced file_get_contents with low-level and binary-safe file reading


<?
function torr(string $filename = ''): mixed
{
   // Array storage
   $torrentInfo = array();
   $array       = array();
   // Torrent Version
   $version     = array();
   // Torrent filename
   $torrent     = explode(".", $filename);
   $fileend     = strtolower(end($torrent));
   if ($fileend == "torrent") {
       $fp    = fopen($filename, 'rb');
       $parse = '';
       while (!feof($fp)) {
           $parse .= fread($fp, 8192);
       }
       fclose($fp);
       // If Parse Lets Read It
       if ($parse === false) {
           echo "Error Getting Torrent file";
       } else {
           // Decode File Array
           $array = Bencode::decode($parse);
           // Push version to Array
           array_push($version, (array_key_exists('meta version', $array['info']) ? intval($array['info']['meta version']) : 1));
           // If Array Lets Read It
           if (empty($array)) {
               die('Unable to decode metadata.');
           } else {
               if (array_key_exists('info', $array) !== true) {
                   die('Error opening torrent');
               } else {
                   // Get Announce URL
                   $torrentInfo['announce']      = isset($array["announce"]) ? $array["announce"] : null;
                   // Get Announce List Array
                   $torrentInfo["announce-list"] = (isset($array["announce-list"])) ? $array["announce-list"] : null;
                   // Calculates date from UNIX Epoch - You want to return NULL on this if empty to pass parse validation
                   $torrentInfo["creation date"] = isset($array["creation date"]) ? date('r', $array["creation date"]) : null;
                   // Get torrents comment
                   $torrentInfo['comment']       = (isset($array['comment'])) ? $array['comment'] : null;
                   // Read info - files
                   $info                         = $array["info"];
                   // The name of the torrents is different to the file name
                   $torrentInfo['name']          = $info['name'];
                   // Read the torrent version stored in array previously
                   $torrentInfo['type']          = $version[0];
                   // Calculate Size/Count
                   $filecount                    = 0;
                   $torrentsize                  = 0;
                   // Calculates Hashes - SHA1/SHA256
                   $torrentInfo['hash']          = in_array(2, $version) ? hash('sha256', Bencode::encode($info)) : hash('sha1', Bencode::encode($info));
                   $path                         = array();
                   // File List
                   $struct                       = in_array(2, $version) ? $info['file tree'] : $info['files'];
                   if (array_key_exists('file tree', $info)) {
                       foreach ($struct as $key => $value) {
                           foreach ($value as $detail) {
                               $filecount = ++$filecount;
                               $torrentsize += $detail['length'];
                               array_merge($path, array(
                                   'length' => $detail['length']
                               ));
                           }
                           array_push($path, array(
                               'length' => $detail['length'],
                               'path' => array(
                                   sizeof($value) - 1 => $key
                               )
                           ));
                       }
                       $torrentInfo['files']       = $path;
                       $torrentInfo['length']      = $torrentsize;
                       $torrentInfo['ttfilecount'] = $filecount;
                   }
                   if (array_key_exists('file tree', $info) || array_key_exists('files', $info)) {
                       if (isset($info['files']) || $filecount > 1) {
                           // Multi File
                           if (isset($info['files']) && is_array($info['files'])) {
                               $torrentInfo['files'] = $info['files'];
                               foreach ($info['files'] as $file) {
                                   $filecount = ++$filecount;
                                   $torrentsize += $file['length'];
                               }
                               $torrentInfo['length']      = $torrentsize;
                               $torrentInfo['ttfilecount'] = !empty($path) ? count($path) : $filecount;
                           }
                       } else {
                           if ($filecount === 1) {
                               // Single File - Remove or Use
                           }
                       }
                   }
               }
           }
       }
   }
   return $torrentInfo;
}
AJAX Bootstrap — 2022-02-06 06:03:24 in Downloads & Updates
Sample code - post updated.
Scrape — 2022-02-06 05:30:04 in v3 Support
Maybe hosting is the issue. My dedicated 1U is in my closet on 2 sturdy Uhaul boxes lol
I have never had a limit in anything I ever wanted to do. I highly recommended just pulling $550US and grabbing a PowerEdge with low specs. Your now left with the commitment of your local LAN.

Hosting is restrictive due to the potential actions by the customer - they eliminate c99 shells, embedded PNGs with <? potential (I actually check images for these on my site, it was very hard to do and took 2 days for my code), root access elevations & buffer overflows - Which is why they disallow certain modules. It could kill their business and all those effected. Look at it as a good thing, however takes a little care to make your endeavors compatible.

Your using PHP, its easy trust me. Python would have you running circles lol
Just keep calm and collective - I have a lot to do and I enjoy helping.

Quote:
Modify the top of torrents-upload.php to look like this. This will let you know what's going on. They should of implemented a exception class for these purposes future-proofing the script itself. Anyway.. do this:

<?
error_reporting(E_ALL);


This will tell us exactly what is going on. A predefined string that tells me very little is not debugging the issue for your script.
bookmarks — 2022-02-06 05:04:07 in v3 Support
You cant use a float value on a LIMIT.

0.25 should be 0,25

row 0 (first row), 25 (next 25 rows)
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 7
  • Members: 0
  • Guests online: 7
  • Comments: 3
  • Messages: 1,728