Results 1 to 4 of 4

Thread: Site Hacked

  1. #1
    Join Date
    Apr 2009

    Site Hacked

    My site's database was getting hacked into through the GET variable of a url that I didn't properly sanitize. I think it's fixed now. But I checked out the remote folder where I stored some images on that page and there were .php files uploaded into it along with other pictures that I never uploaded.

    How does someone upload files through the GET variables of a URL???

    And the .php file that was in this folder was about 7,000 lines long and looked like it was sending out mail at the very end.

    Any idea on what was happening with this website for the past few days??

  2. #2
    Join Date
    Oct 2008
    Not that familiar with security, but from what I've read, I'd guess that the permissions on the folder need to be looked at. I'd search around and google terms like 'web server security' for best practices.

  3. #3
    Join Date
    Jan 2006
    If the $_GET variable is used to get a file, it can also get an external file which can then obtain access to your server. I had a problem like that once, and my solution was to only allow file names that were listed in an array.

  4. #4
    Join Date
    Mar 2010
    Its probably too late now, but the best thing you can do when this sort of thing happens is download all of the raw access logs you can get your hands on for a post mortem analysis.
    The best thing to do though is to develop filtering functions for $_GET, $_POST and $_COOKIE values. You can walk through each as an array and filter each item with a general filter function (will any of your variables need - or _ or `...etc), and can even then use the array's associative index key as an identification for specific variables that require specifc filtering (is the field alphanumeric only), though this method depends on your code style preference.
    Then you should go to each variable individually and apply the filtering at their level too (if $_GET['page'] is passed to $page. then $page=myFilterFunction($_GET['page']); ). This is a multi-layered approach and helps make sure no user vars are unfiltered.
    The filtering should be a whitelist approach if at all possible. This means that instead of saying "This character is bad... and so is this one... and this one...etc", you're actually saying "only this set of characters are good, and all others are bad", this is a far more robust methodology. The more restrictive you make your whitelist filters the better. You can also cast the variable values to specific datatypes before use:


    Which forces the variable to be an int.
    If the variable is for a file of some sort, make sure you limit what it can grab. Again, a whitelist method is best. Create an array or a switch statement with the allowed files, and if the variable matches none, have it select a default file.
    And lastly, use mysql_real_escape_string(); which will properly escape variables before they're used in a database query.
    As mentioned, you may also need to check your directory and file permissions, make sure they only have the permissions they need to operate and no more.
    I could give information on how they were able to upload files... but considering you (probably) don't have raw access logs, and have not shown any code, i would be completely guessing. Without the logs, it is possible they utilized more than one attack vector, but we wouldn't know it (like a server vulnerability for example).
    Last edited by Jarrod1937; 02-03-2011 at 09:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.30162 seconds
  • Memory Usage 2,861KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates