Jump to content

Jason Cooper

Dedicated Members
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Jason Cooper

  1. Does the access point broadcast SSID Beacons? If so then you could put together a simple setup with something like a Raspberry Pi that continually sniffs the SSID Beacons it can see and if it doesn't see the one you're monitoring within the last X seconds it sends an alert.
  2. Have you checked your SELinux logs to make sure that isn't the cause of your problem?
  3. Have you tried the Export-Csv cmdlet? You'll need to squeeze your variables in to an object though. "" | select-object @{Name="Column 1"; Expression={"$variable1"}},@{Name="Column 2"; Expression={"$variable2"}}, @{Name="Column 3"; Expression={"$variable3"}} | Export-Csv -Path "test.csv" -notypeinformation -Encoding UTF8 -Append
  4. Here's how I'd tackle it. The key part is not to break it down to 40 character lines, but instead to take 40 character length sub-strings from the sequence, where each sub-string starts 37 characters on from the start of the previous sub-string. #!/usr/bin/perl my $sequence = "1234567890123456789012345678901234567890123456789012345678901234567890"; my $length = length $sequence; for ( my $i = 0; $i < $length; $i += 37 ) { print substr($sequence, $i, 40) . "\n"; }
  5. For simple deduplication of arrays you can use an associative array/hash. Simply use the word as the key and give it a value of true. Enumerating the keys then gives you the deduplicated list of words. If you want that list sorted then simply sort it afterwards. Here's a quick Perl example: #!/usr/bin/perl use strict; use warnings; my %words; while (my $line = <STDIN>) { chomp($line); $words{lc($line)} = 1; } print join("\n", sort keys %words);
  6. Have you tried a here-string? $testing = "blabla" @" Testing 1 Testing 2 $testing Testing 3 "@ | clip
  7. At the risk of showing my age, the first OS I started on was Tangerine BASIC, on the old Oric Atmos. I'd used CP/M before that but the Oric was where I started to learn how to make the computer do what I wanted, rather than what someone else had told it to do.
  8. That looks very odd to me, as when I try it in powershell it works fine. PS > $folderPath="\\server\folder1\folder2\~folder3" PS > $splitFolder = $folderPath -split '\\' PS > echo $splitFolder[2] server PS > echo $splitFolder[3] folder1 PS > echo $splitFolder[4] folder2 PS > echo $splitFolder[5] ~folder3 In fact if I ask for an array index that doesn't exist I still don't get the error PS > echo $splitFolder[6] PS > I can get the same error you get by misspelling the variable name (e.g. by dropping the 'e' in folder) PS > echo $splitFoldr[6] Cannot index into a null array. At line:1 char:1 + echo $splitFoldr[6] + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray I'd suggest check the spelling (though I can't see any difference in your example) and trying again.
  9. Have you tried using something like: grep -orEH "(sub|new)" * | sed -re's|^([^:]*):(.*)$|\2:\1|' | sort The sed part switches the file name and matched keyword round so that the sort can then sort the output into keyword order. If you don't want duplicates to appear then simply pipe the output through uniq (if you supply uniq with the -c option then it'll give you count of how many times that keyword appears in that file).
  10. Could well be a distro thing, I've tried it in a CentOS 6 based distro and a debian wheezy based distro, and both use HWaddr.
  11. If you know your device's MAC address you can use something like ifconfig | grep "HWaddr XX:XX:XX:XX:XX:XX" | cut -d' ' -f1 Just remember to replace the XX:XX:XX... with your device's MAC address
  12. You probably want to add an input element to your form so that the user can can enter a username of the person they want to make the friend request with, then you'll have a username you can use to look up a user_id from your registeredusers table. Also, while Xorifelse's comment on stack overflow could have been worded better, it is definitely worth learning about parameterized queries (better to learn good habits to start with than have to unlearn bad ones later).
  13. A quick description of what your social network does (or what you want it to do) would be helpful, otherwise we'll just be making broad statements that may or may not be useful, or even correct in the context of your social network. For example, a social network where people join groups and post messages to those groups would require different design to one where users choose to follow others and see everything those others post. Also the underlying technology would be useful to know, e.g. does your PHP use a relational database, a NoSQL database, flat files, etc?
  14. Actually it does explain why it worked, but I'll go into it in a bit more depth. When using the $Group in double quotes it stringifys the value of the object so we have four strings @{Name=@Testone} @{Name=@Testtwo} @{Name=Testthree} @{Name=Testfour} The regular expression the OP provided as a solution is looking for an @ symbol followed by a character that is in the range or a - z, A - Z or 0 - 9. While all four strings start with an @ symbol those are immediately followed by an open brace '{' which doesn't match the pattern that the regular expression is looking for. The first and second strings have another @ symbol which does match the pattern as they're followed by the letter 'T' which is in the range being matched. The OP's solution however doesn't actually meet the criteria of only matching groups starting with an @ symbol as any groups that contain an @ symbol in the middle of their name (e.g. Test@five) as it will be matched by the "`@[a-zA-Z0-0]" regular expression as well.
  15. Seeing your output suddenly makes it all make sense. The $group variable isn't a simple string, it's actually an object with a Name property. When you put it in double quotes Powershell produces a stringified version of the object, which starts with the @ symbol (e.g. "@{Name=@Testone}". You then do a regular expression match against that string, which sees the first character as the @ symbol, which is matches what it's looking for exactly. I don't have access to an active directory to test, but try matching against the $group object's Name propery instead, e.g. $y = Get-ADuser JOEBLOGGS -property MemberOf | % {$_.MemberOf | Get-ADGroup | select Name | sort name} foreach ($group in $y) { if ($group.Name -match "^@") { echo "yep $group" } else { echo "Nope $group" } }
  16. Doesn't -match take a regular expression? If so have you tried "^@" to match a string starting with the @ symbol? What's really interesting though is that you got it returning true for all your groups whether they contained an @ symbol or not, which is something I haven't been able to recreate. e.g. $x = @("@test", "test2", "asd@test3"); foreach ($group in $x) { if ("$group" -match "`@") { echo "yep $group" } else { echo "Nope $group" } } results in yep @test Nope test2 yep asd@test3 while $x = @("@test", "test2", "asd@test3"); foreach ($group in $x) { if ("$group" -match "^@") { echo "yep $group" } else { echo "Nope $group" } } results in yep @test Nope test2 Nope asd@test3
  17. Try #/bin/bash # references the interface wlaninterface=wlan0mon # sets the base file name for the wireless survey recon=scouted # sets the file name for the pcap file to write too pcapfile=DaCapFile # sets the lenth of time to run the survey for - in seconds recontime=30s # sets the lenth of time to run the packet capture for - in seconds capturetime=600s # general house cleaning to remove previous captures rm $recon*.csv &> /dev/null rm $pcapfile*.cap &> /dev/null # setting wlan0 into monitor mode airmon-ng check kill airmon-ng start wlan0 # running the wireless survey airodump-ng -w $recon --output-format csv $wlaninterface &> /dev/null & sleep $recontime kill $! # finds the open WiFi network with the most active traffic and get the channel number channel=$(grep -a 'OPN' $recon*.csv | sort -nrk11 | tail -1 | awk '{print $6}') # removes the comma from the output of the previous line ch=${channel::-1} #finds the open WiFi network with the most active traffic and get the ESSID network=$(grep -a 'OPN' $recon*.csv | sort -nrk11 | tail -1 | awk '{print $19}') # removes the comma from the output of the previous line ssid=${network::-1} #running the packet capture airodump-ng -c $ch --essid $ssid -w $pcapfile --output-format pcap $wlaninterface &> /dev/null & sleep $capturetime kill $! The only change made is that I've moved the house clearing and survey parts so that they run before the you process the survey results. I suspect that in your earlier testing you had an old recon file present which it then used and as the script leaves the recon file on the filesystem at the end you'd only encounter the issue when you moved the script across but not the recon file. The good news is that this bug actually highlighted a logic bug that would be very difficult to spot otherwise (the logic bug was that each time it ran it was using the recon file from the previous time you ran the script not this time, which if you've changed locations wouldn't be much use).
  18. I assume that when you say that it's an array of strings you have something like var messages=[ "message 1", "message 2", "message 3" ]; If it is then the chances are that it's not so much an error caused by the missing semi-colon as a string containing an unescaped quote that's terminating the string too early. I don't think a debugger would help much as it is an error at the compiling stage. Have you tried running jshint against the code? It may narrow down the error a bit more. If jshint doesn't help you track down the source of the problem you could always fall back on a good old binary search to find the source of your problem. Simply comment out the first half of your strings in the array and see if it the error goes away, if it does you know the error is in the first 7,000 strings, if it doesn't you know it's in the last 7,000 strings. Then repeat the process on the block of 7,000 strings with the error in to narrow it down to 3,500 strings, repeat again to narrow it down to 1,750 strings, and keep going till you've narrowed it down to a number of strings that you can actually look at manually.
  19. If you're combining awk, sed and cut together and you're planning on using the code in the long term then you'd probably want to be considering moving over to a Perl or Python script instead for that part, as it will be easier to maintain. I'm not sure on the exact layout of your CSV file, but something like the following might produce the result you're after (you'll probably have to tune the field numbers being used to extract the $bssid and $ivs variables). #!/usr/bin/perl use strict; use warnings; my $maxIVs; my $maxBSSID; while (my $line=<STDIN>) { my @field = split /\s*,\s*/, $line; my $bssid = $field[0]; my $ivs = $field[10]; if (!$maxIVs || $ivs > $maxIVs) { $maxBSSID = $bssid; $maxIVs = $ivs; } } print "$maxBSSID"; If you make the script executable then you can use it in a bash script to populate a variable (you would probably want to change the path to match wherever you put the script). TARGET_BSSID=`./maxIV < test.csv`
  20. Try using ! instead of % to delay the expression evaluation. @echo off setlocal EnableDelayedExpansion FOR %%Z IN (SDESK1 SDESK2 SDESK3 SDESK4) DO ( set UserID=%%Z echo !UserID! )
  21. you need to stop CMD from expanding the environment variables too early (i.e. before %%Z is populated by the for loop) try adding this before the for loop Setlocal EnableDelayedExpansion
  22. Are they acting as routers or switches? If they're acting as routers then you could connect to one and use traceroute to your main router's IP and see what IP's it goes through. You could also fire up wireshark and see what packets are being passed about.
  23. Best advice when first learning to code is to set yourself simple goals. Too many people try to learn to code by tackling a complex problem, but you really need to learn the basic concepts before tackling anything complex. Try creating python scripts to do each of the following: display a message ("hello world" is very common one) accept some input from the keyboard and display a message with it in (perhaps ask the users name then display a hello message to them e.g. "Hello Fred") count from 1 to 10 (e.g. "1 2 3 4 5 6 7 8 9 10") accept two numbers from the keyboard and then output their total accept as many numbers from the keyboard until the user enters something that isn't a number and then display their total accept as many numbers from the keyboard until the user enters something that isn't a number and then display their average
  24. You should always consider what would happen if a function/statement failed, both from a security point of view and reliability point of view. Then you need to consider what the chances are that the function/statement will fail. For something like mysql_real_escape_string the impact of it failing is very high and the chance of it failing is probably average. Having made this judgement then you look to see if there is a better way (hint, read up on paramaterized queries).
  25. Two questions that I would start with: Does it have a documented API available that you can use? If it doesn't have a documented API then walk away, or you'll spend more time on maintaining any thing you get working with the system than you would save. What do you commonly do that you think could be automated? If you're continually making identical actions against the system then perhaps automating those actions will save you some time. Do you have system report that you then have to open new cases for, or do you regularly have to go in and change the state of cases that haven't been updated for a set period?
  • Create New...