heisenbug

Members
  • Content count

    86
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by heisenbug


  1. That's just a simple permutation. Here's how I would do it in perl... 

     

    #!/usr/bin/perluse List::Permutor;$scalar='car';my @array = split(//,$scalar);my $permutor = List::Permutor->new( @array);while ( my @permutation = $permutor->next() ) {    print( join('',@permutation)."\n" );}
    0

  2. In python:

    a = 10

    b = 20

    a = a*2

    b = a/2

    Is this too simplified??

    It's not too simplified (it does take two variables and swap them) but it doesn't do it in a general way, it will only work for certain numbers (i.e., where b = 2a).

    Try and come up with a solution which can work for an arbitrary pair of numbers.

    It is just too easy to do in Python. Don't make it too hard on yourself. Here is the easiest way to do it in Python.


    a,b=b,a

    0

  3. I understand what you are doing with your codes now heisenbug,it's pretty cool how i can pretty much figure out the code in perl and the logic behind it even without really bothering about the perl syntaxes.The recursions are pretty interesting seeing as how google shows how it can be used in multiple situations other then fibonacci number sequences.Thanks for your help =)

    WebNinja

    Glad I could help.

    Most languages are fairly similar if you code cleanly. It's not that hard to learn another once you get the first language down. Some people get lazy with their code and obfuscate it quite a bit, and I could have written the same thing in a perl one liner program, but I specifically made it easy for you to read. Most developers work on a team, and it makes sense to write code in a way that others can understand by a simple glance at it.

    As long as you code cleanly, you should be able to move through languages with ease. Good luck with your programming.

    0

  4. QN1.From what i can make of your subroutine(function?), it pretty much does the same thing as my fibonacci function in the code i posted.However i see that you do not include a break in your for loop, but instead use ($i<$n) where 'i' is the counter and 'n' being the value the user inputs.By doing so, won't your loop output (n-1)counts of fibonacci numbers instead of fibonacci numbers up to the nth value?(which is entered by the user).

    E.g(Assuming n=10)

    your loop will output '0,1,1,2,3,5,8,13,21,34' while my loop will output'0,1,1,2,3,5,8', which is what is requested by the challenge?

    Sorry I thought the challenge was the number of items entered by the user, not the closest fibonacci number. That's an easy fix, it's a while loop instead of a for loop.


    #!/usr/bin/perl

    print "\nHow many numbers of the sequence would you like? ";
    chomp($n = <STDIN>);
    &fibonacci($n);

    sub fibonacci {
    $a = 0;
    $b = 1;
    $n = shift;

    while ($a <= $n){
    printf "%d\n", $a;
    $sum = $a + $b;
    $a = $b;
    $b = $sum;
    }
    }

    QN2.By automatically output i did not mean hardcoding the first 2 fibonacci values(0,1) but by somehow including them into the code in the for loop so that then i run the program,it will simply calculate and output all fibonacci values including the first 2 values(0,1) instead of starting at the 3rd value (which is also 1) as i did.I tried googling fibonacci number sequences in c++ but the only code sample that i could find that seems to output the whole fibonacci sequence was a code that made use of recursion which i have not learnt yet,so i was wondering if there was a way to code the program to automatically output the whole fibonacci number sequence without using recursions.

    You could use the previous code and do-while with two iterations in the do section.

    However, if you really want to play around and have fun with it, a recursive function could be fun with this. You could play with code similar to this....


    sub fibonacci {
    $num = shift;
    $calc = 0;
    if ($num <= 1)
    $calc = $num;
    else
    $calc = fibonacci($num - 1) + fibonacci($num);
    return $calc;
    }

    PS:i dont understand what &fibonacci($n) does though google tells me that $n=shift; does something with arrays.I apologize if my questions were somehow answered by these 2 lines of code.

    Sorry about the shorthand, I didn't want to do your homework for you, but still help you. That's why I didn't give it to you in C.

    Shift just takes the first item off an array. If the array isn't listed, Perl assumes it is @_ and since that is what is passed to the subroutine, that's the passed variable.

    0

  5. 1. Can anyone give me pointers on how to further improve my code

    2. and how to automatically output the first 0 and 1 in the number sequence instead of manually instructing the program to output it?

    This should really go in the programming thread, but since it is a newbie question I'll help.

    PART 1. You are making it much more difficult than it needs to be. Here is the program in Perl.


    #!/usr/bin/perl

    print "\nHow many numbers of the sequence would you like? ";
    chomp($n = <STDIN>);
    &fibonacci($n);

    sub fibonacci {
    $a = 0;
    $b = 1;
    $n = shift;

    for ($i=0;$i<$n;$i++){
    printf "%d\n", $a;
    $sum = $a + $b;
    $a = $b;
    $b = $sum;
    }
    }

    PART 2. To just have it run automatically with only the first two entries, you just hard code it. For example.


    &fibonacci(2);

    0

  6. PFFFFF I'm a network security specialist and can hack anything, I'm the best at hacking GPOs!

    This statement seems like a combination of arrogance and ignorance. It is something that a recent Computer Science graduate would say. The more we learn, the more that opens up, and the more we know we have so much more to learn. In fact, I don't know a single senior level computer scientist that believes they know everything about computers. It is only the ones that haven't delved deep enough into the machine that feel they know it all.

    0

  7. i think ubuntu 10.10 (mm) comes pre loaded with open office? ive been using open office for awhile now and so far so good.

    I wouldn't get into the habit of using software just because it was installed on your computer. I would use the best available software available. Installation isn't that difficult.

    That said, Ubuntu going forward is not going to use OpenOffice due to the Oracle issues. It will be using LibreOffice in the next release (Ubuntu 11.04 on April 28, 2011), so if that is your operating system and you want to future proof your software I would still go with LibreOffice.

    0

  8. Could you explain why should one choose LibreOffice over OpenOffice?

    LibraOffice forked off of OpenOffice. The question you should ask is why was this product was needed and created in the first place. It's because Oracle recently acquired OpenOffice. Oracle is not continuing support of the open source projects it took over from Sun in the spirit of open source. The open source community is not too happy with them. Oracle tends to control the code tightly, and prefer their own developers develop the code. Many people in open source are shunning Oracle and will refuse to work further on OpenOffice.

    It will probably continue to be freeware, but won't get a lot (if any) open source support, especially since Libra Office is out there now. Right now there isn't a lot different with them because the code fork just happened, but over time, LibraOffice will be developed on and embraced by the Open Source community. OpenOffice will not.

    Can you tell this was written by an open source developer??? Ha, oh well. Honestly all bantering aside, without community support and involvement, features will be added that are unimportant to the end user and that cause bloat and important features that end users really need may not always be added. Libra Office will be a better product in general, both physically and ethically.

    EDIT: FORGOT TO REPLY TO CYB3R_THR34T

    Okay one more question, are there any compilers for basic that work in Ubuntu?

    http://www.thefreecountry.com/compilers/basic.shtml

    0

  9. LibreOffice is the open source fork off of OpenOffice. I would suggest LibreOffice.

    Although I would suggest OpenOffice over Microsoft, even on Windows. They will open office documents, and save as them so you should be fine. The display on the "powerpoint" alternative slides are sometimes a little off, but can be fixed easily. Other than that a great alternative.

    I always though Microsoft Works was the biggest oxymoron in technology.

    0

  10. Not a very 56k friendly homepage, looks like a decent forum though. One question did you rip your favicon off from binrev?

    Not a bad board. Anything that promotes hacking and community is a plus in my book. It looks like they both use IPBoard and the favicon is not either binrev's or leethacker's, but belongs to invisionpower, which created the forum software they both use.

    http://www.invisionpower.com/products/board/

    0

  11. Print to the screen the names of all of the Presidents of the United States of America, but hide it in the code in the most obfuscated way you can think of.

    To save time:

    George Washington

    John Adams

    Thomas Jefferson

    James Madison

    James Monroe

    John Quincy Adams

    Andrew Jackson

    Martin Van Buren

    William Henry Harrison

    John Tyler

    James K. Polk

    Zachary Taylor

    Millard Fillmore

    Franklin Pierce

    James Buchanan

    Abraham Lincoln

    Andrew Johnson

    Ulysses S. Grant

    Rutherford B. Hayes

    James Garfield

    Chester A. Arthur

    Grover Cleveland

    Benjamin Harrison

    Grover Cleveland

    William McKinley

    Theodore Roosevelt

    William Howard Taft

    Woodrow Wilson

    Warren G. Harding

    Calvin Coolidge

    Herbert Hoover

    Franklin D. Roosevelt

    Harry S. Truman

    Dwight D. Eisenhower

    John F. Kennedy

    Lyndon B. Johnson

    Richard M. Nixon

    Gerald R. Ford

    James Carter

    Ronald Reagan

    George H. W. Bush

    William J. Clinton

    George W. Bush

    Barack Obama

    0

  12. Here's an easy, but fun one.

    Create the song, "the twelve days of Christmas" in any language from the following...

    String = "On the"

    Array = (First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth)

    String = "day of Christmas, my true love gave to me..."

    Hash = ('Drummers Drumming' => 12,

    'Pipers Piping' => 11,

    'Lords-a-Leaping' => 10,

    'Ladies Dancing' => 9,

    'Maids-a-Milking' => 8,

    'Swans-a-Swimming' => 7,

    'Geese-a-Laying' = 6,

    'Gold Rings' => 5,

    'Colly Birds' => 4,

    'French Hens' => 3,

    'Turtle Doves' => 2,

    'And a Partridge in a Pear Tree.' => 1,);

    0

  13. The hot blondish girl ;).

    Ha, now that's social engineering if I ever saw it. You may be a 400lb man in his mother's basement, but I'll give you the benefit of the doubt and assume this is true. If you are really honestly interested in security I would start with the Black Hat presentations. There are a few on rootkits.

    Black Hat presentations.

    http://www.blackhat.com/html/bh-media-archives/bh-multimedia-archives-index.html

    0

  14. Truth is i found the Laptop and intend keeping it but can't access the system without the password. In this case whats the best tool to use to hack the password?

    After seeing your post #4, I withdrawal my advice.

    After reading your comment #4 I also got really annoyed. I agree with Berzerk on this. Correct me if I am wrong, but it seems you don't know the difference between petty theft and hacking.

    Here is what I consider the difference:

    HACKING -

    1. Taking a computer, and figuring out a way to bypass the password.
    2. Disseminating the contents of the drive to find the owner's name, address, and pictures of them to identify them.
    3. Being nice and installing programs to help them find their PC if they lose it again.
      • VNC - (to view the system)
      • An SSH server - (to help retrieve their files)
      • An IP beacon - (To say when the PC is online and what the IP address is)

    [*]Returning the laptop to the owner.

    [*]Occasionally checking in on the PC to make sure the system is ok, and they didn't lose it again. (What a good citizen!!!)

    PETTY THEFT -

    • Not using google to find a simple kiddie script.
    • Being an idiot and telling everyone you are committing a crime.

    5

  15. Hi

    I have a DELL Laptop that needs a password (Not known) to enter the operating system (Windows Vista) how do i get around this? Would i need to change the hard drive and install a new OS with a new license, is that an option? or is there a 3rd party app that could hack this?

    Yes, you can wipe the drive and install a fresh copy of Windows, or Linux (free); however, you will lose all of your data. You can recover that data by booting from a Linux CD. Ubuntu Live CD or knoppix will work well for this. Once you boot up, you will be able to access the NTFS formatted hard drive and copy the files you need to a USB drive.

    If you bought the PC used, I wouldn't use the same OEM (Microsoft Product ID) or the same MAC Address. You don't know if the guy before you was some kiddie porn collector or something. I would suggest removing the partitions, formatting the drive, encrypting the entire drive, and installing a fresh Operating System after that.

    If it was always your PC, and you just forgot your 35 digit password with lowercase, uppercase, numbers and special characters. I haven't used it, but I hear Kon-Boot works well to strip the passwords.

    1

  16. The bitwise sqrt operation.

    I love this famous piece of code.


    float Sqrt(float x) {
    float xhalf = 0.5f*x;
    int i = *(int*)&x;
    i = 0x5f3759df - (i>>1);
    x = *(float*)&i;
    x = x*(1.5f-xhalf*x*x);
    x = 1/x;
    return x;
    }

    0

  17. 8 bit adder -- In Perl...


    #!/usr/bin/perl
    my ($value1,$value2) = @ARGV;
    $carry=$sum=0;
    $numOfBits = 8;

    for ($bit = 0; $bit < $numOfBits; ++$bit) {
    $bitValue = 1 << $bit;
    $bitA = $value1 & $bitValue;
    $bitB = $value2 & $bitValue;
    $sum = $sum | ( ( $bitA ^ $bitB ) ^ $carry );
    $carry = ( ( $bitA & $bitB) | ( $carry & ( $bitA ^ $bitB ) ) ) << 1;
    }
    print $sum;

    0

  18. Perl with a regular expression.


    #!/usr/bin/perl
    chomp($input = <STDIN>);
    $input =~ s/\&r/\[31m/g;
    $input =~ s/\&g/\[32m/g;
    $input =~ s/\&o/\[33m/g;
    $input =~ s/\&b/\[34m/g;
    $input =~ s/\&p/\[35m/g;
    $input =~ s/\&c/\[36m/g;
    $input =~ s/\&w/\[37m/g;
    print $input;

    0

  19. Well, first off, NEVER trust user input.

    When inserting records into a mysql database, always sanitize the input by using mysql_real_escape_string (http://php.net/manual/en/function.mysql-real-escape-string.php)

    Also, when using $_POST[] or $_GET[], you need to sanitize that input as well by using stripslashes, or such.

    Incorporating this into any code you do will help you tremendously.

    Another thing is, since you are building a CMS, apart from just password protecting the admin page, be sure to use an htaccess. The htaccess should only allow by certain ip's you own.

    Example of .htaccess:


    AuthUserFile /home/test/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Administrative Portal"
    AuthType Basic

    <limit GET>
    satisfy any
    order deny,allow
    deny from all
    allow from 127.0.0.1
    allow from 221.23.249.294
    require valid-user
    </limit>

    You must place this .htaccess in the directory of your CMS admin page/directory. This will only allow the ip's listed to access your admin page.

    Another thing, is when you include files, don't do something like the following:

    <?php
    include($includedir."/config.php");
    ?>

    If your PHP config is not config'd properly, someone can do an include on your website and use a php shell to take over your website as well as your server.

    These are the basics, I hope it helps. If anyone has anything else to add, please do.

    If only a few people you know are going to be using this, then create a certificate and require the browser to have it.

    You might want to protect yourself from SQL injections. Striping out semi-colons is important. Also less than, greater than, equals signs, etc... And if it doesn't need to be in there, INSERT, DELETE, DROP, UPDATE, etc. (No one should have a First Name, Age, Etc of DROP or UPDATE)

    Use dropdown menus, check-boxes, radio buttons, etc whenever possible. The option they pick better damn well be one of the choices you gave them. If it isn't then I would just log their IP and exit out of the script.

    -1

  20. I think that it's interesting when people say, "I use Mac for the hardware", or "I just use Windows because my Dell came with it." Isn't this a hacker forum?

    I have switched operating system many, many, many times. I find operating systems fascinating, and have delved into the depths of many. Even as far as contributing code to distributions. I use a few different ones, but I have my favorites.

    I don't think it matters what came on your box, if people like Mac then they can install a Hackintosh, or if they like Windows they can install that too. I don't think people should keep a closed mindset on operating systems. They should use what they like best. If they like what OS came on the hardware in the first place, then awesome...use that; however, most just use it because they can't fathom that an operating system can be changed.

    Hardware != Software

    0