frida error `TypeError: cannot write property 'implementation' of undefined` - instrumentation

I am trying to inject the below script using frida
function main() {
Java.perform(function () {
let fhs = Java.use("com.tencent.mm.protocal.protobuf.fhs");
fhs.da.implementation = function (bArr) {
console.log('da is called' + ', ' + 'bArr: ' + bArr);
let ret = this.da(bArr);
console.log('da ret value is ' + ret);
return ret;
};
})}setImmediate(main)
Throws the below error
TypeError: cannot set property 'implementation' of undefined
at <anonymous> (/a.js:11)
at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:11)
at _performPendingVmOps (frida/node_modules/frida-java-bridge/index.js:238)
at <anonymous> (frida/node_modules/frida-java-bridge/index.js:213)
at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:11)
at _performPendingVmOpsWhenReady (frida/node_modules/frida-java-bridge/index.js:232)
at perform (frida/node_modules/frida-java-bridge/index.js:192)
at main (/a.js:12)
at apply (native)
at <anonymous> (frida/runtime/core.js:45)
command i am using frida -U com.tencent.mm -l ./Desktop/a.js --no-pause
Below one is the decompiled code of the apk file.
public final fhs da(byte[] bArr) {
AppMethodBeat.i(2376);
net.a.a.a.a aVar = new net.a.a.a.a(bArr, unknownTagHandler);
for (int nextFieldNumber = getNextFieldNumber(aVar); nextFieldNumber > 0; nextFieldNumber = getNextFieldNumber(aVar)) {
if (!populateBuilderWithField(aVar, this, nextFieldNumber)) {
aVar.kqf();
}
}
fhs kuW = kuW();
AppMethodBeat.o(2376);
return kuW;
}

Related

createProperty sabre\vobject Uncaught TypeError

I am using the calendar plugin for RoundCube Webmail, any time i am trying to create an event, I receive the following error:
[12-Apr-2022 17:56:08 UTC] PHP Fatal error: Uncaught TypeError: Sabre\VObject\Document::createProperty(): Argument #3 ($parameters) must be of type array, null given, called in /var/www/html/plugins/libcalendaring/libvcalendar.php on line 939 and defined in /usr/share/php/Sabre/VObject/Document.php:103
The functions:
public function createProperty($name, $value = null, array $parameters = null, $valueType = null){
// If there's a . in the name, it means it's prefixed by a groupname.
if (false !== ($i = strpos($name, '.'))) {
$group = substr($name, 0, $i);
$name = strtoupper(substr($name, $i + 1));
} else {
$name = strtoupper($name);
$group = null;
}
$class = null;
if ($valueType) {
// The valueType argument comes first to figure out the correct
// class.
$class = $this->getClassNameForPropertyValue($valueType);
}
if (is_null($class)) {
// If a VALUE parameter is supplied, we should use that.
if (isset($parameters['VALUE'])) {
$class = $this->getClassNameForPropertyValue($parameters['VALUE']);
if (is_null($class)) {
throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"');
}
} else {
$class = $this->getClassNameForPropertyName($name);
}
}
if (is_null($parameters)) {
$parameters = [];
}
return new $class($this, $name, $value, $parameters, $group);
}
Call it:
$vdt = $cal->createProperty($name, $dt, null, $is_dateonly ? 'DATE' : 'DATE-TIME');
Does anyone know how to fix this?

IntelliJ IDEA Live Template Groovy script error

I've created a Groovy script based Live Template for DataGrip, but it always throws a startup error but it works on online groove executor:
def result = '';
def i=1;
_1.split().eachWithIndex { item, index ->
def ans = '';
if (_2=='id' && index==0) {
return;
} else if (_2=='uuid' && index==0) {
ans = 'gen_random_uuid()';
} else {
ans = '$'+i;
i++;
}
if (index.next() != _1.split().size()) {
ans= ans + ','
}
result = result + ans
};
return result;
Here is the error:
startup failed:
Script1.groovy: 1: expecting '}', found 'if' # line 1, column 267.
'$' + i;
i++;
} if (index.
^
1 error
Solution is to put a semicolon after each if closes.

Raku Native call gtk-clipboard-request-text?

How would you call this library with Raku/Perl6's Native Call?
https://developer.gnome.org/gtk3/stable/gtk3-Clipboards.html#gtk-clipboard-request-text
void
gtk_clipboard_request_text (GtkClipboard *clipboard,
GtkClipboardTextReceivedFunc callback,
gpointer user_data);
Many thanks,
-T
Edit: this question was HOW to call the function. Not to troubleshoot a failed call. No code was written at this point.
The following seems to work:
use v6;
use NativeCall;
constant GdkAtom := uint64;
constant GDK_NONE = 0x0;
sub gtk_init(Pointer $argc, Pointer $argv) is native('gtk-3') { * };
sub gdk_display_get_default() returns Pointer is native('gdk-3') { * };
sub gtk_clipboard_get_for_display(Pointer $display, GdkAtom $selection)
returns Pointer is native('gtk-3') { * };
sub gtk_clipboard_request_text(
Pointer $clipboard,
&callback ( Pointer $clipbrd, Str $text, Pointer $data),
Pointer $user_data) is native('gtk-3') { * };
sub gtk_main() is native('gtk-3') { * };
sub gtk_main_quit() is native('gtk-3') { * };
gtk_init(Pointer, Pointer); # Pass NULL for arguments
my $display = gdk_display_get_default();
my $clipboard = gtk_clipboard_get_for_display( $display, GDK_NONE );
my $callback = my sub (Pointer $clipboard, Str $text, Pointer $data) {
say "In callback: Text = $text";
gtk_main_quit();
}
gtk_clipboard_request_text( $clipboard, &$callback, Pointer );
gtk_main();
This will print the text that is currently on the system's default clipboard.

hive querying records for a specific uniontype

I have a sample hive table created as
CREATE TABLE union_test(foo UNIONTYPE<int, double, array<string>, struct<a:int,b:string>>);
The data can be viewed as
SELECT foo FROM union_test;
The output is
{0:1}
{1:2.0}
{2:["three","four"]}
{3:{"a":5,"b":"five"}}
{2:["six","seven"]}
{3:{"a":8,"b":"eight"}}
{0:9}
{1:10.0}
the first field (tag) denotes the type of the union ( 0 for int, 1 for double, 2 for array etc).
My problem is if I found to select only those records where the union type is 2 (array), how should I frame my query?
There is no function in Hive to read data from UnionType. So i wrote 2 UDF´s. One to get Union tag (that you trying to do) and second to get struct from union as an example.
get_union_tag() function:
package HiveUDF;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.UnionObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
#Description(name = "get_union_tag", value = "_FUNC_(unionObject)"
+ " - Returns union object Tag", extended = "Example:\n" + " > SELECT _FUNC_(unionObject) FROM src LIMIT 1;\n one")
public class GetUnionTag extends GenericUDF {
// Global variables that inspect the input.
// These are set up during the initialize() call, and are then used during the
// calls to evaluate()
private transient UnionObjectInspector uoi;
#Override
// This is what we do in the initialize() method:
// Verify that the input is of the type expected
// Set up the ObjectInspectors for the input in global variables
// Return the ObjectInspector for the output
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
// Verify the input is of the required type.
// Set the global variables (the various ObjectInspectors) while we're doing this
// Exactly one input argument
if( arguments.length != 1 ){
throw new UDFArgumentLengthException("_FUNC_(unionObject) accepts exactly one argument.");
}
// Is the input an array<>
if( arguments[0].getCategory() != ObjectInspector.Category.UNION ){
throw new UDFArgumentTypeException(0,"The single argument to AddExternalIdToPurchaseDetails should be "
+ "Union<>"
+ " but " + arguments[0].getTypeName() + " is found");
}
// Store the ObjectInspectors for use later in the evaluate() method
uoi = ((UnionObjectInspector)arguments[0]);
// Set up the object inspector for the output, and return it
return PrimitiveObjectInspectorFactory.javaByteObjectInspector;
}
#Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
byte tag = uoi.getTag(arguments[0].get());
return tag;
}
#Override
public String getDisplayString(String[] children) {
StringBuilder sb = new StringBuilder();
sb.append("get_union_tag(");
for (int i = 0; i < children.length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append(children[i]);
}
sb.append(')');
return sb.toString();
}
}
function get_struct_from_union() UDF :
package HiveUDF;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.UnionObjectInspector;
#Description(name = "get_union_struct", value = "_FUNC_(unionObject)"
+ " - Returns struct ", extended = "Example:\n" + " > _FUNC_(unionObject).value \n 90.0121")
public class GetUnionStruct extends GenericUDF {
// Global variables that inspect the input.
// These are set up during the initialize() call, and are then used during the
// calls to evaluate()
//
// ObjectInspector for the list (input array<>)
// ObjectInspector for the struct<>
// ObjectInspectors for the elements of the struct<>, target, quantity and price
private UnionObjectInspector unionObjectInspector;
private StructObjectInspector structObjectInspector;
#Override
// This is what we do in the initialize() method:
// Verify that the input is of the type expected
// Set up the ObjectInspectors for the input in global variables
// Return the ObjectInspector for the output
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
// Verify the input is of the required type.
// Set the global variables (the various ObjectInspectors) while we're doing this
// Exactly one input argument
if( arguments.length != 1 ){
throw new UDFArgumentLengthException("_FUNC_(unionObject) accepts exactly one argument.");
}
// Is the input an array<>
if( arguments[0].getCategory() != ObjectInspector.Category.UNION ){
throw new UDFArgumentTypeException(0,"The single argument to AddExternalIdToPurchaseDetails should be "
+ "Union<Struct>"
+ " but " + arguments[0].getTypeName() + " is found");
}
// Set up the object inspector for the output, and return it
return structObjectInspector;
}
#Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
return ((UnionObjectInspector) unionObjectInspector).getField(arguments[0].get());
}
#Override
public String getDisplayString(String[] children) {
StringBuilder sb = new StringBuilder();
sb.append("get_union_vqtstruct(");
for (int i = 0; i < children.length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append(children[i]);
}
sb.append(')');
return sb.toString();
}
}
to use these UDF´s compile and create jar file. Than upload into hive (in my case HDInsight). Than just use
add jar wasb:///hive/HiveGUDF.jar;
CREATE TEMPORARY FUNCTION get_union_struct AS 'HiveUDF.GetUnionStruct';
before u run e.g.
SELECT get_union_tag(exposed) FROM test;

Make sort using delegates

I'm try to make a sort delegate in C++/CLI, but, when I try to compile I recive this erro:
>app.cpp(256): error C3374: can't take address of 'Program::AnonymousMethod1' unless creating delegate instance
>app.cpp(256): error C2664: 'void System::Collections::Generic::List<T>::Sort(System::Comparison<T> ^)' : cannot convert parameter 1 from 'System::Object ^(__clrcall *)(Program::teste1,Program::teste1)' to 'System::Comparison<T> ^'
> with
> [
> T=Program::teste1 ^
> ]
> No user-defined-conversion operator available, or
> There is no context in which this conversion is possible
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
here is the code sample of the error:
using namespace System;
using namespace System::Collections::Generic;
private ref class Program
{
private:
enum class tokens
{
teste,
lala,
blabla,
};
ref struct teste1
{
int linha;
tokens tk;
};
private:
static Object ^AnonymousMethod1(teste1 p1, teste1 p2)
{
return p1.tk.CompareTo(p2.tk);
}
public:
Program()
{
bool jump = false;
List<teste1^>^ lstTest = gcnew List<teste1^>();
Random ^rnd = gcnew Random();
for (int i = 0; i < 20; i++)
{
teste1 ^tst = gcnew teste1();
switch (rnd->Next(1,4))
{
case 1:
tst->tk = tokens::teste;
break;
case 2:
tst->tk = tokens::lala;
break;
case 3:
tst->tk = tokens::blabla;
break;
}
lstTest->Add(tst);
}
for each (teste1^ content in lstTest)
{
Console::WriteLine(content->tk.ToString());
}
lstTest->Sort(AnonymousMethod1);
Console::WriteLine("==============================================================");
for each (teste1^ content in lstTest)
{
Console::WriteLine(content->tk.ToString());
}
}
};
int main(array<String^> ^args)
{
Program^ prg = gcnew Program();
return 0;
}
I just whant to sort the list with the token 'lala' first, how I can make this, and, How I can solve this ???
Your List is of type List<test1^> (notice the ^ hat). So the Comparison<T> delegate you want is Comparison<teste1^>. Thus you'll want to change your AnonymousMethod1 as follows:
static int AnonymousMethod1(teste1 ^ p1, teste1 ^ p2)
{
return p1->tk.CompareTo(p2->tk);
}
And in C++/CLI you need to explicitly create your delegate:
Comparison<teste1 ^> ^ comparisonDelegate = gcnew Comparison<teste1 ^>(&AnonymousMethod1);
lstTest->Sort(comparisonDelegate);