反盗链 (Anti-Leech)

Reference
[1] Apache 防盗链(Apache Anti-Leech)技术的简单实现
[2]web网站防盗链技术_八种常见的防盗链方法总结

1. 判断引用地址

  • 使用 rewrite 技术实现 Apache 防盗链
  • 通过refer变量的值,判断图片或者资源是否合法
    • 缺点: refer可以被伪造

2. 使用cookie

  • 其实这种方法原理上跟方法2差不多。就是在显示“下载”链接的页面里产生一个动态值的cookie,然后在处理资源下载请求时先判断cookie里有没有正确的cookie,如果没有则返回错误提示信息。至于这个动态值如何产生,只要能逆向判断动态值是否合法的都可以,例如将当前的时间去除秒数取哈希值(也叫散列值)。如果网页程序是asp.net则更简单,可以往Session里随便存一个字符串或数字,然后在处理下载请求时先检查Session里是否存在这个字符串或数字。
    • 缺点
      • 无法使用下载工具

3. 使用动态文件名
  • 也叫动态钥匙法,当用户点击一个下载链接时,先在程序端计算一个Key(使用一定规律产生的Key,最好不要使用随机字符串例如GUID,并且这个Key必须有一定时效的),然后在数据库或Cache里记录这个Key以及它所对应的资源ID或文件名,最后让网页重定向一个新的URL地址,这个新URL地址里需要包含这个Key。当浏览器或下载工具发出下载请求时,程序先检测这个Key是否存在,如果存在则返回对应的资源数据。
  • 使用这个方法的好处是下载工具也可以下载,并且在Key失效前可以断点续传,并且可以通过Key来控制下载的线程数。
  • 使用这个方法(包括以上所有支持下载工具的方法)的缺点是:当任意一个用户下载成功之后,你的资源就会被一些下载工具列入“资源候选名单”,以后其他人在其他地方下载同样的文件时,下载工具会不断连接你的服务器,即使你的文件已经删除或者Key已经失效了,
    • 这样会造成类DDos攻击的后果,下面再介绍两个即可以让下载工具下载,又可以防止盗链的方法。

4. 擅改资源的内容

  • 一般热门的资源都是电影、mp3、较大的压缩包等,这些文件都是有很多可以插入数据的地方的,例如mp3有一个tag区,rar/zip有一个备注区,电影的内容随便一个地方,只要在下载过程当中,动态地往这些地方注入一些随机的字节(几个字节即可),就可以达到让整个文件的哈希值(即散列值、指纹值)发生改变,让从你网站下载的文件的哈希值跟别人的不一样,就可以防止下载工具主动找上门了。用这个方法配合方法6,可以达到较好的防盗链的效果。缺点是,虽然文件被修改的部分不会被“看”、“听”出来,不过多多少少让知道的人觉得不爽。另外就是如果别人把从你网站下载的文件放到其他网站,那么仍然存在下载工具主动找上门的情况(虽然实际上它下载不了内容)。


[VA 22031] Marumen 拉面馆

评分: 70/100
Yelp 链接:http://www.yelp.com/biz/marumen-fairfax-2
价格: 拉面12, 额外配料0.5-2不定,炸猪皮 3.5
从昨天下午上课的时候就一直想着吃拉面,无奈昨天自己带了晚饭。今天下午迫不及待地奔去吃。
虽然这家店不是很正宗,但VA附近也没有其它拉面馆啦。面条不是很有嚼劲,并且配料很少,只加了豆芽菜,海苔片以及半个溏心蛋 (竟然还是甜的,口味有点怪啊!)。 其它配料需要自己加钱,可以加玉米,竹笋 等。汤头挺浓的,应该是猪骨汤,不油腻刚刚好。
另外一个特点就是餐前会送小吃,今天送了毛豆。我们另外还点了炸猪皮,吃起来脆脆的,有脂肪的香味,不过对我来说稍微有点辣。

餐前送的毛豆
炸猪皮


拉面


The meaning of doing research

06/17/2015
I am interning in a tech company this summer. My mentor is a very smart, humorous, and happy guy. He got his Ph.D. degree from C, one of my dream school.

I am inspired by his opinion towards technology and the meaning of pursuing Ph.D. degree.

  • It is important to understand how technology interacts with the marketplace. Technology that truly changes the way we work and live must keep both the technical and market aspects in mind.

Self-Discipline has potential to be ruined by Ph.D

04/15/2015

Today, I saw a discussion in Huaren forum [Link]

Guys there were discussing about whether the self-discipline is determined by congenital factor (先天)or by nurture (后天). It is very interesting and also surprising that many people said they have very good discipline before they enter the Ph.D. program! But when they enter the Ph.D. program, they suffer a lot and become to have procrastination (拖延症).

The reasons that they tend to have procrastination after entering the Ph.D. program are
  • Outside the Ph.D. program, everything has a very clear goal and if you work toward goal, you can see you make progress step by step. But things are different in Ph.D. program, you need to find a topic by yourself, and it is not easy to envision the outcome.
  • Someone said in the forum that the motivation of self-discipline is “I am good at something, if I keep working on this, I will be much better than anyone else”.
  • If you have no positive feedback, it is easy for you to give up.
  •  People around you are very excellent, and you found no matter what you do, you cannot catch up with them. As a consequence, you feel upset. 
  • My comment: Win-win will be better. Learn excellent qualities from others! I don’t think this is good reason for upset to come from.

Therefore, in order to be a productive Ph.D. student, there are some actions we can take

  • Do something you are good at. For example, I am working on algorithm but I am not good at making proof. Therefore, a better way for me is to find some application for algorithms and do some simulation.
  • Find short goal for yourself. Divided the big goals into small pieces and complete each one step by step.
  • Someone said self-discipline is like muscle. If you not keep training, the muscle will atrophied (萎缩). Lol
  • Thinking in a different way. Many successes is due to the cumulative acquisition of knowledge.

If you are hurt by the Ph.D. life and would like to strike a way out to get a different life, here are some suggestions
  • You may be procrastinated because you are doing something that you are not interested at all. If it were this case, then I encourage to find something you really like. 

Amy Morin: 13 Things Mentally Strong College

Here are the 13 things mentally strong college students don’t do:
  1. Waste Time Feeling Sorry for Themselves
    Many of life’s problems and sorrows are inevitable, but feeling sorry for yourself is a choice. Whether you’re drowning in student loan debt, or you’re struggling to pass Advanced Calculus, indulging in self-pity won’t fix your problems. If you’re prone to feeling sorry for yourself when the going gets rough, train your brain to exchange self-pity with gratitude. Mentally strong people don’t waste their time and energy thinking about the problem, instead they focus on creating a solution.
  2. Give Away Their Power
    It can be tempting to blame other people for when we face problems and experience uncomfortable emotions. Thinking things like, “My professor makesme feel bad about myself,” however, gives others power over you. Take back your power by accepting full responsibility for how you think, feel, and behave. Empowering yourself is an essential component to building mental strength and creating the kind of life you want to live.
  3. Shy Away From Change
    Although we feel safest when we stay within our comfort zones, avoiding new challenges serves as the biggest obstacle to living a full and rich life. Acknowledge when you’re avoiding change simply because you want to escape the discomfort associated with doing something new. Commit to facing those emotions head-on. The more you practice tolerating uncomfortable emotions, the more confident you’ll become in your ability to tolerate the distress that may be necessary to reach your full potential.
  4. Waste Energy on Things They Can’t Control
    So often, we worry about all the wrong things. Rather than focus on preparing for the storm, we waste energy wishing the storm wouldn’t come. If we invested that same energy into the things we do have control over, we’d be much better prepared for whatever life throws our way. Pay attention to the times when you’re tempted to worry about something you can’t control — like your roommate’s GPA or how the job market is going to look when you graduate — and devote that energy into something more productive.
  5. Worry About Pleasing Others
    Although a lot of people say, “I don’t care what other people think,” that’s often a defense mechanism meant to shield them from the hurt and pain associated with rejection. The truth is, most of us want to be liked and we want those around us to be happy. But choosing a major based on what your parents want you to do, or accepting an internship that a professor wants you to take, can interfere with your ability to create your own path in life. Doing things that won’t be met with favor takes courage, but living a truly authentic life requires you to live according to your values, even when your choices aren’t popular.
  6. Fear Taking Calculated Risks
    We make dozens – if not hundreds – of choices every day with very little consideration of the risks we’re taking. And in college, calculating those risks fall on your shoulders for the first time. It’s up to you decide everything from what you’re going to do on Friday night to what career path you’re going to take. Often we base those choices on emotion, rather than the true level of risk. Making decisions based on your level of fear isn’t an accurate way to calculate risk because emotions are often irrational and unreliable. You don’t get to be extraordinary without taking risks, but it’s important to learn how to accurately calculate those risks so you can make choices with confidence.
  7. Dwell on the Past
    While reflecting on the past and learning from it is a helpful part of building mental strength, ruminating can be harmful. Whether you were bullied in junior high, or still can’t believe you didn’t pass that class last semester, dwelling on it will only hold you back. Although moving forward can be hard – especially if you’ve endured your share of misfortune – it’s a necessary step to becoming your best self.
  8. Make the Same Mistakes Over and Over
    It’d be nice to learn enough from each mistake that we’d be guaranteed to never repeat that same mistake twice. But, how many times have you said, “I’ll never do that again,” only to find yourself right back at it a few days later. Learning from our mistakes requires humility and a willingness to look for new strategies to become better. Mentally strong people don’t hide their mistakes or make excuses for them. Instead they turn their mistakes into opportunities for self-growth.
  9. Resent Other People’s Success
    No matter where you go to college, you’re bound to be surrounded by people who are prettier, smarter, wealthier, and more successful. Focusing on all the things other people have however, will interfere with your ability to reach your goals. When you’re secure in your own definition of success, you’ll stop resenting other people for obtaining their goals and you’ll be committed to reaching your dreams.
  10. Give Up After Failure
    It’s normal to feel embarrassed, discouraged, and downright defeated when your first attempts don’t work. From a young age, we’re often taught that failure is bad, but it’s nearly impossible to succeed if you never fail. Mentally strong people view failure as proof that they’re pushing themselves to the limits in their efforts to reach their full potential.
  11. Fear Alone Time 
    In today’s fast paced world, obtaining a little quiet time often takes a concerted effort. Many people avoid silence and solitude because the lack of activity feels uncomfortable. But taking time for yourself is an essential component to building mental strength. It’s essential to create opportunities to be alone with your thoughts so you can reflect on your progress and consider your goals for the future.
  12. Feel the World Owes Them Anything
    It’s easy to get caught up in feeling a sense of entitlement. But waiting for the world — or the people in it — to give you what you think we’re owed isn’t a helpful life strategy. If you’re busy trying to take what you think you deserve, you won’t have any time to focus on all that you have to give. And everyone has gifts that can be shared, regardless of whether they’ve gotten a “fair deal” in life.
  13. Expect Immediate Results
    We often grow so accustomed to our “no lines, no waiting” world, that our brains begin to believe that everything should happen instantaneously. But self-growth develops at more of a snail’s pace, rather than at lightning speed. Whether you’re trying to lose weight or you want to improve your self-confidence, slow and steady wins the race and expecting immediate results will only lead to disappointment. Mentally strong people know that true change takes time and they’re willing to work hard to see results.
The good news is, everyone has the ability to build mental strength. But to do so, you need to develop self-awareness about the self-destructive thoughts, behaviors, and feelings that prevent you from reaching your full potential. Once you recognize areas that need work, commit to mental strength exercises that will help you create healthier habits and build mental muscle.