How to recursively remove text from hacked PHP files; or Reading the Man pages, being a man, and not dancing around the question

So you login to your website only to find OMG WE’VE BEEN HAXX0RED!@#!@! Which quite frankly sucks.   It could be any number of issues, but let’s say you suffer from the condition where someone has inserted some encrypted block of txt at the top of each PHP file to execute when you launch the files.

You can fix it, one by one but that’s annoying as all hell and lengthy… going into vi for each file, deleting the first line, rinse, repeat, AHHHH!!!!

So you search the internet with various phrases like “remove text from php file” “how to strip txt out of files” “recursively fix hacked php worpress” I mean the list can and DOES go on, but the point is you end up on Forums and blogs where people are like LET ME SHOW YOU HOW IT’S DONE, resulting in them basically telling you to read the Man Pages.  Hey douche-bag, be a MAN and tell me exactly what I need to do.  The time to ‘learn’ how to do it is all fine and dandy for AFTER I have the problem resolved!   It’d be like going to the Mechanic to get your car fixed and having him laugh at you for not knowing what is wrong, and not fixing it until you can explain how you’d fix it yourself.  Guess what, you’re a dick and this is not a time for a learning lesson!

This is a time for a learning lesson!

If you happen to find yourself in the position to needing to ‘strip’ an arbitrary string of information from one or more files, here’s a way to do it, with an explanation of what each line of this means!

find . -type f -print0 | xargs -0 sed -i ‘s/.*zend.*//g’ *.php

So, some of you may be wondering, “Well, crap that works! I fixed it! but what does it mean and how do I use this to my benefit in the future?!” Here is a breakdown of the syntax and some alternative selections you can choose, and I’ll be explaining it in ‘reverse’ because that’s sort of how it is executing.

sed -i ‘s/.*zend.*//g’ *.php

    sed is a stream editor which with the –i flag is telling the system to edit files “in place” saving out to the original file as opposed to saving to another file name or type. You’ll notice that it calls “’s/” which is to “substitute” the contents of the following which is a search string, in this case *zend.* and what follows the “/g’” helps you choose what to replace the contents with, and in this case, the content will be nothing, e.g. truncate the line.

And lastly the “*.php” at the end specifies on what file types we want to perform this command against.  We could easily choose “*.htm” or even “*”

xargs –0

     What exactly does this mean? Well, this tells the system to expect a ‘null’ character, this is often used in accord with find and –print0 as below

find . –type f –print0

   What is going on here, is the system is going ‘find’ based upon the parameters we specified in the other areas (e.g. *.php) initiating at the current directory of “.”   But then what we get is “-type f” basically tells the system to indicate that a host has been identified as having that ‘string’ of text to replace, and “-print0” will then print out what the “filename” was.

How this basically sums up is the system starting at a base directory starts searching through all subdirectories looking for files which have a certain string of text in them.  When it finds that string of text the print0 will tell xargs to print the name of the file which HAD the string of text.  With the filename identified then sed will step in an execute the ‘replacement’ of the string of text, which in this case basically deletes it.   It continues searching through the directory structure until it has exhausted the criteria of finding .php files which have the data in mind.

Now, you’re not limited to using ‘sed’ for this, you could just as easily run with using “grep –Ev” to find and replace the string of text for you, it really comes down to what you’re comfortable with and how you want to cut it.

Hopefully the lesson here is… Here is a solution to a problem that some of you WILL suffer from in your life and hell, I can go back to use this script again in the event that one of my sites I manage gets screwed up again.    Respectively with a little effort you can use this to find and replace text in files in your environment, say modifying host files en-masse or changing DNS in resolv.conf throughout your environment… Whatever floats your boat!

Special thanks to my twitter friends who tossed out VARIOUS ways to do this!   @Fr3d_org @davidchapa @cody_bunch

Hopefully you found this useful, I sure as hell did!

Fixing “Comments are closed” problems on WordPress Blogs with Social

There you are, sitting there posting an absolutely awesome blog post which is getting a LOT of attention. OMG THE HITS JUST KEEP COMING IN! EVERYONE KEEPS SAYING HOW AWESOME IT IS. Yet no one is commenting on it on the blog. WTF is going on here!   So you take a moment to browse over to your blog post everyone is so enamored with only to find in the comments section.

Comments are closed.

And you start freaking out. WTF IS GOING ON HERE!?!? I DIDN’T CLOSE COMMENTS.   It’s strongly possible, that you didn’t.  But you can fix this.

When this happened to me just the other day I immediately started doing searches for “Wordpress Comments are closed” “Wordpress comments disabled” “disabled comments” and every other iteration of it, only to find… a whole REAM of absolutely useless and piece of crap posts and forum conversations which did NOT help.   A lot of them refer to checking the “Discussions” area in the control panel of wordpress… Yea, that doesn’t change over night.

But I also recall some time ago having made a change from using Twitter Tools to “Social” because they claimed the tools I PREFERRED were no longer supported or would function, so upgrades will need to be done.

Here is the kicker, if you are using Social by MailChimp that could be the cause of your problem, so next steps involve visiting your WordPress Control Panel

And you may come across this little gem:

Social by MailChimp may be disabling your comments with it's "Social's Comment Display" - Check the box to re-enable your comments!

Turns out that Social has integrated it’s own Comment Display system… which I’ve never seen and could give a damn for since it essentially BROKE my comments.   So by taking the next step and by checking the box….

By checking "Disable Social's comment display" your old Disqus or other comments should be re-enabled!

All of a sudden my blog went from “Comments are closed.” to enabled and allowing people to COMMENT again! Hooray, right!

If you find this benefits or is useful to you, feel free to COMMENT and let me and everyone else know :)  Also if you do come across other solutions you wish to share in the comments, don’t hesitate to make it known!  Good luck and good commenting!

TOS Exposed: My Instagram photos are FOR SALE At half what Instagram are offering!

Aren’t you OUTRAGED by the change in Terms of Service by our good friends at Instagram and Facebook effective January 16th?  First, let’s look at the ‘changes’ in question.   These top 2 seem to be the charge of outrage by most news beat writers because they clearly got a buzz that this is what they’re supposed to talk about and be outraged at.

Proprietary Rights in Content on Instagram; Instagram does NOT claim ANY ownership rights in the text, files, images, photos, video, sounds, musical works, works of authorship, applications, or any other materials (collectively, "Content") that you post on or through the Instagram Services. By displaying or publishing ("posting") any Content on or through the Instagram Services, you hereby grant to Instagram a non-exclusive, fully paid and royalty-free, worldwide, limited license to use, modify, delete from, add to, publicly perform, publicly display, reproduce and translate such Content, including without limitation distributing part or all of the Site in any media formats through any media channels, except Content not shared publicly ("private") will not be distributed outside the Instagram Services.

This is what everyone seems to be screaming about OMG INSTAGRAM SAYS THEY CAN SELL MY PHOTOS AND NOT EVEN NOTIFY ME ABOUT IT, IM NOT GETTING PAID FOR IT! After all of the whine and cheese has been appropriately distributed, and considering that some 1billion photos get posted every second, what are the odds that YOUR particular photo of a cat drinking water from the faucet was going to be SOLD by instagram in the first place? The odds, aren’t very likely, but I understand you’re outraged because they are selling something which you had no means of selling to start with, providing a vehicle to share with others on an extensive infrastructure, DAMNIT WTF WHY DIDN’T WE WRITE SOMETHING LIKE THIS OURSELVES! (Whew, glad I didn’t write this in 1999….. but I digress) But let’s focus on the real matter at hand here, okay? Those of you who are pissed off that your rights are being ‘trampled’ on weren’t long for the service in the first place.

Taking a look at the rest of the ‘rules’ in question…

You represent and warrant that: (i) you own the Content posted by you on or through the Instagram Services or otherwise have the right to grant the license set forth in this section, (ii) the posting and use of your Content on or through the Instagram Services does not violate the privacy rights, publicity rights, copyrights, contract rights, intellectual property rights or any other rights of any person, and (iii) the posting of your Content on the Site does not result in a breach of contract between you and a third party. You agree to pay for all royalties, fees, and any other monies owing any person by reason of Content you post on or through the Instagram Services. 

Okay, you’re saying THIS IS MINE AND IF IT’S COPYWRITTEN IT’S MY FAULT AND MY LIABILITY. Okay, that’s standard legalize way of saying “uh… it’s your fault if we screw up because we said don’t publish that stuff on our site anyway! Neener Neener – Instagram” Right?  So now when you take a photo of a coke can SIMILAR to that in which another company did for pay… you have to pay ROYALTIES on it, but not Instagram them self…. okay, that’s a CYA if I ever saw one…

The Instagram Services contain Content of Instagram ("Instagram Content"). Instagram Content is protected by copyright, trademark, patent, trade secret and other laws, and Instagram owns and retains all rights in the Instagram Content and the Instagram Services. Instagram hereby grants you a limited, revocable, nonsublicensable license to reproduce and display the Instagram Content (excluding any software code) solely for your personal use in connection with viewing the Site and using the Instagram Services.

What isn’t clear here is what is defined as “Instagram Content” because by some of the other statements.. ALL content might be technically defined as “Instagram Content” but for the purpose of argument we’ll assume for a moment this does not equally include Content of Users– which brings us to the next point.    You may not copy/modify/display/sell any content “appearing” on the Instagram Services.   So, what is this saying?  If I took a photo myself, and shared a copy of it on Instagram that I no longer have right to my ORIGINAL SOURCE of content since it WAS shared on Instagram?   This has gotten to be some of the worst written legalize I’ve seen in some time, so either they want a blanket WE OWN YA’LL BITCHES to mean all content generated ever, or they really have no fricking idea how to write a legal document.   Either way, I stand forth, even reading into this content….

Feel free to use the content I generate and share on Twitter, Instagram and Facebook as a virtual ‘Gallery’ of my offerings, and you the general purpose world and community and welcome to Purchase under license to USE that content in a commercial context.    Though, as I addressed years ago, otherwise I’m open to a creative commons discussion for pretty much most any other purpose, and this ToS can go screw itself because it doesn’t have a gram to stand upon.   

If you find yourself fleeing the service, get over yourself if you’re that vain.    If you’re an artist and you feel your ‘property’ is going to be thieved by the man, then close the door on another opportunity to get your name and your work out there.   But if you’re an artist for the sake of art like myself who likes to stick it to the man, continuing producing content without fear of what ‘the man’ will do to us, because honestly… We are the content generators, the Service does not exist if not for us, and if they cannot ‘sell’ content to drive advertisers to pay them money, well, there’s no fricking infrastructure to run this on, so go back to your ‘paid’ services which no one will ever see your content on.

kthxbye.

How to REALLY Mass Unfollow on Twitter! (OMG IT’S FREE AND EASY?!?!)

I’ve written on this subject a number of different times (See bottom of post for all of the various links on this matter!)    However what I am going to share here has been not a secret per se, I just never got around to SHARING how to do it, as I was busy actually USING it as a tool! OMG, right?!

Disclaimer: The following tool is FREE for 1000 Unfollows PER DAY. It cannot be used for Following FOR FREE.  Which is why I manually follow back using the twitter.com Webpage. It’s monotonous and slow as hell, but it is what I do!   But at least there is an answer to the unfollow!

BEGIN THE MASS UNFOLLOW ON THE TWITTER! :)

It all starts with logging in to the ManageFlitter Website.

Manage Flitter Start  ManageFlitter Connect to Twitter ManageFlitter is indexing your contacts!

These three steps run so inline it’s so simple! Click “Start” choose to “Connect to Twitter” which sets up an Auth against your acct with creds, and then it pulls in the database of who you are following and who is following you.  VERY SIMPLE. Basically mindless.

ManageFlitter unfollow those not following you! Check baby check baby 1-2-3 You have unfollowed people, OMG THE HORROR!!!

Then it provides a list of various categories.   If you want to unfollow people NOT following you, then simply select that category (defaulted) and go and CHECK the boxes of people you want to unfollow.   Wow, it’s that simple! Then simple choose “Unfollow selected” and you’re DONE!

BUT WAIT! THERE’s MORE!!!

Twitter “Rules” dictate that they cannot give you a “Check all boxes” option or else this would be so much easier. But in the effort of CHEATING, I advise you download a tool like “CheckFox” which will allow you to Check ALL of the boxes on the webpage [Up to 100 per page] and mass-unfollow those 100.

Then simply rinse-repeat and go from page to page to page until you’ve either unfollowed everyone you want to, or you’ve hit your 1000 limit for the day.

Either way, this has MASSIVELY cut what it takes to unfollow. Yay, right?   But it’s not limited to who isn’t following you.  You can choose people who’ve NEVER tweeted if you want, or who have no profile picture, or are TOO Active or INACTIVE. (I’d fall into the  “Too Active” category! ;)

There isn’t a whole lot more to add to this.  It’s clear, succinct, and straight forward :) If you know of OTHER tools like this which are as easy and free, mention it!   And if you have follow-back tools, mention them! I’ve stopped looking!

Links:

How to mass follow and unfollow on twitter FOR FREE?!?!?

How to mass follow and unfollow on twitter: over 10k club!

How to mass unfollow or follow people on Twitter .. and more!

How to mass follow and unfollow on twitter FOR FREE?!?!?

Yea baby, you heard me! For FREEEEEE!!! This functionality existed in the past and then twitter stripped it away (unfortunately) There were numerous ways which I covered in the past here

How to mass unfollow or follow people on Twitter .. and more

How to mass follow and unfollow on twitter: over 10k club!

But then it all went away.. until NOW! (Again ;))

Featuring Twitter Mutuality!

Twitter Mutuality - How to mass follow and unfollow users on twitter for free

I decided to give this a try today – Why not (I had hit an odd condition where I had a bunch of people I was not following but should have been!) so I decided to give it a try.

First I used three of my test accounts in order to ensure that it would actually function/work, and if it didn’t or my account was compromised I’d be able to simply change the password and move on.    It seemed to function and operate as expected… so I took it to the next level.

Lo and behold, BAM!  It worked! It not only worked though.. it worked VERY well, VERY fast and extremely efficient.  All for the major price of $0 (Wow!)

Is my account compromised? Will they use my credentials for evil? (This does not use oAuth for verification, so it’s VERY possible they’re storing your credentials in some database for major exploitation.   My advise there – Use the tool if you want and then change your creds… Until I get confirmation one way or the other of how safe and legit this may be (I seem fine for now) you can take advantage of the tool and move on.

In the past I’ve discussed tools which had limits for having over 10K followers/following.  This tool does not seem to be even phased by my 16k followers, so take that to heart and take advantage of this! If this works for you and you like it, be sure to let me know in the comments or on twitter @cxi :)