This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

Eraser, one of the funny advanced Internet nerds.

For ten years, I have finally mastered the essence of code poisoning. Behind these advanced skills are the most unpretentious basic knowledge.

The code is written in Python

Low toxicity

Through the exception return information, directly to the user to throw a solution, that is, to improve the coding speed, but also to the user has an account, the code response speed is fast. For example, in a customer service system, when you receive a customer complaint, you can poison it like this.

# Customer feedback function
def feedback() :
	return "Your complaint has been received, thank you for your advice, we seriously rectification!"
Copy the code

Complaints are your business, codes are mine.

However, our goal is not to poison the user, but to poison the code.

So replicate that scenario for a collaborative r&d project. The two departments of Party A and Party B cooperate in the development. The R&D personnel of Department B can directly return a text when the program is abnormal, for example, contact Lao Meng (R&D personnel of Party A).

Call a function of party B
def call_func() :
	# do something
	# omit 100 lines of code here...
	#
	try:
    	# do something
	except:
	    raise "If anything abnormal occurs, please contact Lao Meng (XXX Company)"
Copy the code

If you think the above code, the poison site is too easy to find, the naked eye, that is no problem, change to the following code.

try:
   	# do something
except:
    raise "\u5982\u51fa\u73b0\u5f02\u5e38\uff0c\u8bf7\u8054\u7cfb\u8001\u5b5f\uff08\u0058\u0058\u0058\u516c\u53f8\uff09"
Copy the code

With Unicode encoding conversions, the arcane tricks are often hidden in the basics.

Medium poison

Variable poison technology, the cost is very low, the effect is excellent.

for _ in range(10) :for __ in range(20) :print(_,__)
Copy the code

The code above is just a small Tops, once you master this technique, the code you write will encrypt itself.

summer = "tianqi change"
sumner = "tianqi no change"
sunmer = "tianqi no no change"
Copy the code

This fine distinction of variables allows others to constantly exercise their ability to pay attention to details when reading codes, which helps them to quickly improve their glasses.

High toxic

Skilled use of list generators in Python, such as the code below, is very toxic.

shuiguos = [The word "apple"."Orange"."Banana"."Pear"]
xuhaos = [1.2.3.4]
jiages = [12.0.7.0.9.0.10.0]
my_list = [(x, s, j) for s in shuiguos for x in xuhaos for j in jiages if j < 10]
print(my_list)
Copy the code

Variables using Chinese pinyin + English plural.

The generator loops directly over three layers, suggesting unlimited stacking. After using it, the reader is guaranteed to exclaim repeatedly and burst out the undulating words: “lie (4)X”, “lie (4)X”, “lie (2)X”, “lie (2)X(3)?” The variable X above represents a plant.

Shouldn’t, shouldn’t, writing articles excited, dedicated, honest, friendly.

poisonous

If that doesn’t work for you, you can use the eval function to get you started in Python.

name = eraser
s = "name"
name = eval(s)
print(name)
Copy the code

It’s a simple piece of code, but you put it in a function, and it looks great. This is the most common code, the most likely to create a crater operation, if the string does not satisfy you, can be modified to look like this.

x = "Rubber"
y = "Skin"
z = "Brush"
s = '[x,y,z]'
There are dozens of lines of code here
print(eval(s))
Copy the code

Not toxic enough? Continue to modify, the better the foundation, the more code (), combined with high toxic writing method, get the following code.

shuiguos = [The word "apple"."Orange"."Banana"."Pear"]
xuhaos = [1.2.3.4]
jiages = [12.0.7.0.9.0.10.0]
bat = eval(
    "[(x, s, j) for s in shuiguos for x in xuhaos for j in jiages if j < 10]")
print(bat)
Copy the code

After I run it, I hear a sound in front of my computer that’s not enough. What about the one below?

shuiguos = [The word "apple"."Orange"."Banana"."Pear"]
xuhaos = [1.2.3.4]
jiages = [12.0.7.0.9.0.10.0]
bat = eval("[(x, s, j) for s in shuiguos for x in xuhaos for j in jiages if j < 10]", {
    "xuhaos": [5.6.7.8]."jiages": [12.0.7.0.9.0.10.0]}, locals())
print(bat)
Copy the code

The poison of intangible

What’s the most advanced poison technique? That must mean he didn’t even know he was poisoning her.

A lot of the time, you don’t want to poison the code, but you poison it because of the dish (hit in the face), this is the highest level of skill, no trick in mind, no trick in hand.

  1. Careless, overload system function, let teammates puzzling;
  2. Accidentally, overload operator, let teammates take medicine;
  3. Careless, with global variables, let teammates call straight dig grass;
  4. skr~

I am eraser, a funny advanced Internet worm. Pay attention to me, while learning technology, while happy smile.

Share your secret or toxic experience in the comments section

Don’t poison your colleagues