获取网页中所有的文字

# encoding=utf8

import sys

reload(sys)

sys.setdefaultencoding('utf8')

import re
import requests
from bs4 import BeautifulSoup


html = requests.get('https://mp.weixin.qq.com/s?src=11×tamp=1533887718&ver=1051&signature=Xszdx5nmmHyebcH0MXxyHi7-jDwGoNDUDXCHJzPVic68tXGRSTiM3CStUDfSR*aALaC3nK3Ez4e33uLR5ir1pLgy3vEvWXWOvVXgAbsXMn5fB-HWboOW26GH*KMRVhgX&new=1')
soup = BeautifulSoup(html.text, "html5lib")
data = soup.findAll(text=True)


def visible(element):
    if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
        return False
    elif re.match('', str(element.encode('utf-8'))):
        return False
    return True


result = filter(visible, data)

with open('res.txt', "w+") as p:
    for i in result:
        print(str(i))
        p.write(str(i))


print list(result)

django 1452, ‘Cannot add or update a child row: a foreign key constraint fails

网上这个问题搜索的概率非常高,但是实际上解决方法并不是非常完美,例如删除数据库重建什么的。由于刚开始的时候没有设计用户模块,中间添加的用户模块,此时数据库已经有很多数据了,如果删除数据重新创建是显然不可能的,于是搜索了一下,https://blog.csdn.net/qingche456/article/details/58153741 这个帖子中的方法确实能够解决问题,但是并不是十分完美,作为一个强迫症患者,一定要解决这个问题,而不是用这种投机取巧的办法。

我这里出现这个问题的原因在于,新建的用户表用户数量已经超过了原有的auth_user数据数量,所以外键已经无法获取到正确的用户id。原始的约束如下

ADD CONSTRAINT `django_admin_log_user_id_52fdd58701c5f563_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);

而我新创建的用户model为h4ckUser_hackuser,于是新创建的用户都会增加到h4ckUser_hackuser表中,而不是默认的auth_user表中。要解决这个问题就需要修改外键约束,我用phpmyadmin
后台发现无法修改这些数据。于是只好重建一个新表,然后将两个表名称替换。此时这个问题就完美解决了,新建的表注意将上面的代码改成
ADD CONSTRAINT `django_admin_log_user_id_52fdd58701c5f563_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `h4ckUser_hackuser` (`id`);
此时在后台新建用户以及各种操作就完全没有问题了,日志系统也会正常进行记录。
另外如果migrate失败,可以尝试删除migration下最后生成的文件,同时对数据库中新增加的数据进行删除。然后重新直接make migraions和migrate,为了稳妥还是最好天前进行系统备份,例如快照系统和mysql备份。

CommentView Plugin for IDAPro7.0

自从ida升级7.0 之后,hexrays做了很多的改动,以前的插件基本都废掉了。于是想要找个插件就变得很困难,最近分析一个文件需要获取所有的注释,但是那个针对低版本开发的commentview已经无力回天了。虽然晚上有开源的代码,但是实际修改起来比较蛋疼,不知道是不是ida的问题,编译的插件获取的地址基本都是错误的。还是按照以前的使用区段枚举,和inf信息获取的方法获取到的地址都错了,着tm就很尴尬了,测试代码如下:

for (int i = 0; i < get_segm_qty(); i++) {
        segment_t *seg = getnseg(i);
        qstring segname;
        get_segm_name( &segname,seg, 1024);
        msg("segname: %s, start_ea= %08x, end_ea= %08x , size=%08x \n", segname.c_str(), seg->start_ea, seg->end_ea, seg->size());
    }
msg("Database Info: start_ea= %08x, min_ea= %08x, max_ea= %08x, omin_ea= %08x, omax_ea= %08x \n", inf.start_ea, inf.min_ea, inf.max_ea, inf.omin_ea, inf.omax_ea);
    msg("lowoff= %08x, highoff= %08x, main= %08x \n", inf.lowoff, inf.highoff, inf.main);

实际获取到的数据如下,测试环境为OSX + IDA 7.0,如果谁看到了这篇文章还获取到了正确的地址麻烦通知我一声(感谢匿名用户的评论反馈:那个基址问题应该是IDA的BUG,在新的IDA 7.0.171130 (SP1)里已经修正了的,如果是正版的话就升级一下吧。)。

segname: .text, start_ea= 10001000, end_ea= 00000001 , size=effff001 
segname: .idata, start_ea= 10005000, end_ea= 00000006 , size=efffb006 
segname: .rdata, start_ea= 1000513c, end_ea= 00000003 , size=efffaec7 
segname: .data, start_ea= 10006000, end_ea= 00000005 , size=efffa005 
Database Info: start_ea= 10007000, min_ea= ff000000, max_ea= 00000000, omin_ea= 0006000f, omax_ea= 06400007 
lowoff= 00500046, highoff= 00000301, main= 10007000 

获取到的end_ea都是错的。

Continue Reading

xcode 9.2 集成obfuscator-llvm

Obfuscator-LLVM is a project initiated in June 2010 by the information security group of the University of Applied Sciences and Arts Western Switzerland of Yverdon-les-Bains (HEIG-VD).

The aim of this project is to provide an open-source fork of the LLVM compilation suite able to provide increased software security through code obfuscation and tamper-proofing. As we currently mostly work at the Intermediate Representation (IR) level, our tool is compatible with all programming languages (C, C++, Objective-C, Ada and Fortran) and target platforms (x86, x86-64, PowerPC, PowerPC-64, ARM, Thumb, SPARC, Alpha, CellSPU, MIPS, MSP430, SystemZ, and XCore) currently supported by LLVM.

对于这个插件,网上的安装文章相对来说还是挺多的,例如官方的文档https://github.com/obfuscator-llvm/obfuscator/wiki/Installation,再例如 http://www.exchen.net/ios-hacker-obfuscator-llvm-xcode%E9%9B%86%E6%88%90%E9%85%8D%E7%BD%AE.html。已经写的都非常详细了,按照上面的文章基本都可以配置好了,唯一需要注意的是如果xcode的版本不同,对应的里面的字符串可能不一致,例如:

<string>Apple LLVM 8.0</string> -> <string>Obfuscator 4.0</string>

如果用的是xcode9 那么应该是Apple LLVM 9.0。同时如果在编译之前没有安装cmake,可以通过homebrew来安装还是非常方便的。

brew install cmake

Homebrew installs the stuff you need that Apple didn’t.

如何安装homebrew请参考这个链接:https://brew.sh/

如果不想跳转上面的链接,直接在终端中执行下面的安装代码即可:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

这里想说的是安装完成之后,还可能会出现别的问题,例如提示编译的时候提示下面的信息:

clang-4.0: error: cannot specify -o when generating multiple output files
Continue Reading

discuz x3.x 论坛图片不显示 none.gif

废话不多说,我遇到的情况是换了模版之后图片就不显示了。于是感觉是js出了问题,搜索图片的标签名称,找到了两个不同的js。并且在正在使用的js里面中文乱码了,如下图。解决方法也很简单,直接上传原始js替换掉现在使用的js。出现这个问题的原因在于模版转换工具从gbk转到utf的时候出了问题,事实上js文件不用转换。

另外如果遇到同样的问题,也有可能是别的原因导致的,如果切换模版之后出现上面的状况,可以参考我的方法。另外的原因请参考这个链接;

https://www.baidu.com/baidu?tn=monline_3_dg&ie=utf-8&wd=discuz+%E5%9B%BE%E7%89%87%E4%B8%8D%E6%98%BE%E7%A4%BA+none.gif