Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                PrintUsage();
                return;
            }

            if (args[0] == "friends")
            {
                FindInFriendsCsv(args);
                return;
            }

            if (args[0] == "singlePhone")
            {
                FindSingle(args, phone: true);
                return;
            }

            if (args[0] == "singleId")
            {
                FindSingle(args, phone: false);
                return;
            }

            if (!File.Exists(args[1]))
            {
                Console.WriteLine("Provided contacts file does not exist!");
                PrintUsage();
                return;
            }

            var contactsCsv = File.ReadAllLines(args[1])
                              .Select(s => s.Split(","))
                              .SelectMany(s => GetPhoneEntries(s, args[0]))
                              .DistinctBy(s => s.phoneNumber)
                              .ToDictionary(s => s.phoneNumber, s => s.name);

            if (!File.Exists(args[2]))
            {
                Console.WriteLine("Provided leak file does not exist!");
                PrintUsage();
                return;
            }

            StreamReader facebook = new(args[2]);
            string       line;

            while ((line = facebook.ReadLine()) != null)
            {
                var record = new FacebookLeakRecord(line);
                if (contactsCsv.ContainsKey(record.PhoneNumber))
                {
                    Console.WriteLine($"{contactsCsv[record.PhoneNumber]}, {record.PhoneNumber}, {record.Name} {record.Surname}");
                }
            }
        }
Ejemplo n.º 2
0
        private static void FindSingle(string[] args, bool phone = false)
        {
            string checkValue = args[1];

            if (phone)
            {
                checkValue = NormalizeNumber(args[1]);
            }

            var          found    = false;
            StreamReader facebook = new(args[2]);
            string       line;

            while ((line = facebook.ReadLine()) != null)
            {
                var record = new FacebookLeakRecord(line);
                if (phone ? record.PhoneNumber == checkValue : record.UserId == checkValue)
                {
                    found = true;
                    Console.WriteLine($"Phone number: {record.PhoneNumber}");
                    Console.WriteLine($"UserId: {record.UserId}");
                    Console.WriteLine($"Name: {record.Name} {record.Surname}");
                    Console.WriteLine($"E-mail: {record.EmailAddress}");
                    Console.WriteLine($"Birthdate: {record.BirthDate}");
                    Console.WriteLine($"Gender: {record.Gender}");
                    Console.WriteLine($"Workplace: {record.Workplace}");
                    Console.WriteLine($"Living in: {record.LivingIn}");
                    Console.WriteLine($"Coming from: {record.ComingFrom}");
                    Console.WriteLine($"Relationship status: {record.RelationshipStatus}");
                    return;
                }
            }
            if (!found)
            {
                Console.WriteLine("No such data found.");
            }
        }
Ejemplo n.º 3
0
        private static void FindInFriendsCsv(string[] args)
        {
            var friends = File.ReadAllLines(args[1])
                          .Where(l => !string.IsNullOrWhiteSpace(l))
                          .Select(l => l.Split(";"))
                          .Select(l => new { UserId = l[0], UserName = l[1], FullName = l[2] })
                          .DistinctBy(l => l.UserId)
                          .ToDictionary(l => l.UserId);

            StreamReader facebook = new(args[2]);
            string       line;

            while ((line = facebook.ReadLine()) != null)
            {
                var record = new FacebookLeakRecord(line);
                if (friends.ContainsKey(record.UserId))
                {
                    var friend = friends[record.UserId];
                    //Console.WriteLine($"{friend.FullName}, {record.PhoneNumber}, {record.Name} {record.Surname}");

                    Console.WriteLine($"Phone number: {record.PhoneNumber}");
                    Console.WriteLine($"UserId: {record.UserId}");
                    Console.WriteLine($"Name: {record.Name} {record.Surname}");
                    Console.WriteLine($"E-mail: {record.EmailAddress}");
                    Console.WriteLine($"Birthdate: {record.BirthDate}");
                    Console.WriteLine($"Gender: {record.Gender}");
                    Console.WriteLine($"Workplace: {record.Workplace}");
                    Console.WriteLine($"Living in: {record.LivingIn}");
                    Console.WriteLine($"Coming from: {record.ComingFrom}");
                    Console.WriteLine($"Relationship status: {record.RelationshipStatus}");

                    Console.WriteLine();
                    Console.WriteLine();
                }
            }
        }